I am having trouble while trying to make a getFeature request to a WFS server. I can make getCapabilities and describeFeatureType request.
String getCapabilities = "http://cbsservis.tkgm.gov.tr/tkgm.ows/wfs?SERVICE=WFS&REQUEST=Getcapabilities";
Map<String, String> connectionParameters = new HashMap<String, String>();
connectionParameters.put("WFSDataStoreFactory:USERNAME", "cbsdemouser");
connectionParameters.put("WFSDataStoreFactory:PASSWORD", "lp+12345");
connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL",
getCapabilities);
try {
DataStore data = DataStoreFinder.getDataStore(connectionParameters);
String typeNames[] = null;
typeNames = data.getTypeNames();
String typeName = typeNames[0];
SimpleFeatureType schema = data.getSchema(typeName);
System.out.println("Schema Attributes:"
+ schema.getAttributeCount());
SimpleFeatureSource source = data.getFeatureSource(typeName);
System.out.println("Metadata Bounds:" + source.getBounds());
FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools
.getDefaultHints());
DefaultQuery query = new DefaultQuery(typeName, Filter.INCLUDE);
query.setMaxFeatures(2);
SimpleFeatureCollection features = source.getFeatures(query);
String fid = null;
Iterator<SimpleFeature> iterator = (Iterator<SimpleFeature>) features
.features();
while (iterator.hasNext()) {
SimpleFeature feature = (SimpleFeature) iterator.next();
fid = feature.getID();
System.out.println(fid);
}
But when I tried to make a getFeature request, I got this errors:
WARNING: Unexpected response "401 Unauthorized" while downloading http://cbsservis.tkgm.gov.tr/tkgm.ows/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=TKGM%3Aadalar
Eyl 08, 2015 10:23:45 AM org.geotools.data.wfs.v1_0_0.NonStrictWFSStrategy createFeatureReaderGET
WARNING: java.io.IOException: org.xml.sax.SAXException: Failed to resolve
Eyl 08, 2015 10:23:45 AM org.geotools.data.wfs.v1_0_0.NonStrictWFSStrategy createFeatureReaderPOST
WARNING: java.io.IOException: Server returned HTTP response code: 500 for URL:
Related
I want to get the list of corpora.
curl -X GET --header "Authorization: Bearer xxxxxxxx(about 1200 characters IAM token)" "https://https://gateway-syd.watsonplatform.net/speech-to-text/api/v1/customizations/zzzzz(customization_id)/corpora"
result(This curl command succeeds.)
{"corpora": [
{
"out_of_vocabulary_words": 0,
"total_words": 10,
"name": "corpusname",
"status": "analyzed"
},
...
but...in Java,
HttpURLConnection urlConn = null;
try {
String urlStr ="https://https://gateway-syd.watsonplatform.net/speech-to-text/api/v1/customizations/zzzzz(customization_id)/corpora";
URL url = new URL(urlStr);
urlConn = (HttpURLConnection) url.openConnection();
String token = xxxxxxxx; // about 1200 characters IAM token
urlConn.setRequestProperty("Authorization", "Bearer " + token);
urlConn.setRequestMethod("GET");
urlConn.connect();
int status = urlConn.getResponseCode();
String resMessage = urlConn.getResponseMessage();
System.out.println("## HTTPStatus:" + status + " - " + resMessage); // "## HTTPStatus:400 - Bad Request"
} catch (xxx) {
// ...
}
result(failure)
## HTTPStatus:400 - Bad Request
I used same IAM token...
Why this error occurs?
(I'm sorry that I am not good at English.)
=============added 2020/03/03
I used watson SDK(ver.6.9.2). But another error(403) occurs...
IamOptions options = new IamOptions.Builder()
.accessToken(token)
.url(urlStr) // String urlStr = https://gateway-syd.watsonplatform.net/speech-to-text/api/v1/customizations/zzzzz(customization_id)/corpora
.build();
SpeechToText speechToText = new SpeechToText(options);
System.out.println();
ListCorporaOptions listCorporaOptions = new ListCorporaOptions.Builder()
.customizationId(customizations_id) // String curstomization_id = zzzzz
.build();
List<Corpus> corpus = speechToText.listCorpora(listCorporaOptions)
.execute()
.getCorpora(); // status: 403, error: Forbidden
System.out.println(corpus.get(0));
error:
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[ForbiddenException: Forbidden]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:251)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:178)
at play.core.server.AkkaHttpServer$$anonfun$1.applyOrElse(AkkaHttpServer.scala:363)
at play.core.server.AkkaHttpServer$$anonfun$1.applyOrElse(AkkaHttpServer.scala:361)
at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:413)
at scala.concurrent.Future$$Lambda$6244/000000001ECBEAD0.apply(Unknown Source)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
at scala.concurrent.impl.Promise$$Lambda$3716/00000000172D40F0.apply(Unknown Source)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
Caused by: com.ibm.watson.developer_cloud.service.exception.ForbiddenException: Forbidden
at com.ibm.watson.developer_cloud.service.WatsonService.processServiceCall(WatsonService.java:474)
at com.ibm.watson.developer_cloud.service.WatsonService$WatsonServiceCall.execute(WatsonService.java:532)
at controllers.Controller.getCorpora(Controller.java:147)
at router.Routes$$anonfun$routes$1.$anonfun$applyOrElse$52(Routes.scala:1412)
at router.Routes$$anonfun$routes$1$$Lambda$6727/000000001FB17820.apply(Unknown Source)
at play.core.routing.HandlerInvokerFactory$$anon$3.resultCall(HandlerInvoker.scala:134)
at play.core.routing.HandlerInvokerFactory$$anon$3.resultCall(HandlerInvoker.scala:133)
at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$8$$anon$2$$anon$1.invocation(HandlerInvoker.scala:108)
at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:88)
at play.http.DefaultActionCreator$1.call(DefaultActionCreator.java:31)
Just use the Watson Java SDK!
https://cloud.ibm.com/apidocs/speech-to-text/speech-to-text?code=java#get-a-corpus
The example that Mike pointed to won't work with version 6, which is 2 major versions back. Can you update to version 8 of the SDK? See the migration guide.
Then your authentication code would be different and the example in the API reference should work:
IamAuthenticator authenticator = new IamAuthenticator("{apikey}");
SpeechToText speechToText = new SpeechToText(authenticator);
speechToText.setServiceUrl("{url}");
replace {url} with https://api.au-syd.speech-to-text.watson.cloud.ibm.com or https://gateway-syd.watsonplatform.net/speech-to-text/api
and replace {apikey} with your key.
I'm struggling with an REST-Service written with JAX-RS.
I want to create and bind a client with the following code:
final String DEFAULT_RESOURCE_URL = "http://someURL:8180/";
try {
ResteasyClient client = new ResteasyClientBuilder().build().register(ClientResponseLoggingFilter.class);
ResteasyWebTarget target = client.target(DEFAULT_RESOURCE_URL).path(
"service/document/getdrawingbrowser/{documentId}/{documentType}/{partDocumentId}/{documentVersion}/{userName}");
HashMap<String, Object> keyValuesMap = new HashMap<String, Object>();
keyValuesMap.put("documentId", "xxxx");
keyValuesMap.put("documentType", "yyy");
keyValuesMap.put("partDocumentId", "000");
keyValuesMap.put("documentVersion", "000");
keyValuesMap.put("userName", "user");
Builder responseBuilder = target.resolveTemplates(keyValuesMap).request();
Response response = responseBuilder.get();
if (response.getStatus() == 200) {
byte[][] documents = response.readEntity(byte[][].class);
for (int i = 0; i < documents.length; i++) {
displayProperties(documents[i]);
}
} else {
Object entity = response.getEntity();
System.out.println(entity);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
The REST-Service responds correctly I guess:
status: 200
date: Mon Sep 14 10:53:02 CEST 2015
last-modified: null
location: null
headers:
Connection :keep-alive,
Content-Disposition :attachment; filename=someFile.pdf,
Content-Type :application/octet-stream,
Date :Mon, 14 Sep 2015 08:53:02 GMT,
Server :WildFly/8,
Transfer-Encoding :chunked,
X-Powered-By :Undertow/1,
media-type: application
But in line 102 byte[][] documents = response.readEntity(byte[][].class); I'm getting an javax.ws.rs.ProcessingException which says:
javax.ws.rs.ProcessingException: Unable to find a MessageBodyReader of content-type application/octet-stream and type class [[B
at org.jboss.resteasy.core.interception.ClientReaderInterceptorContext.throwReaderNotFound(ClientReaderInterceptorContext.java:39)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:73)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:50)
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:59)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(ClientResponse.java:248)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(ClientResponse.java:181)
at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(BuiltResponse.java:217)
at DocumentTest.main(DocumentTest.java:102)
I have tried several .jar files and some approaches from here and here, but sadly, none of them worked out...
Any ideas?
Try to change you Content-Type to application/pdf.
I create a RESTful web service and write a client to use it . but when I run it i take HTTP 400 Bad Request : javax.ws.rs.BadRequestException exeption . this is my client code :
String webserviceURI = "http://localhost:8084/fsc-access";
ClientConfig clientConfig = new ClientConfig();
Client client = ClientBuilder.newClient(clientConfig);
URI serviceURI = UriBuilder.fromUri(webserviceURI).build();
WebTarget webTarget = client.target(serviceURI);
MultivaluedMap formData = new MultivaluedMapImpl();
formData.add("plate", plate);
formData.add("startTime", start.toString());
formData.add("endTime", end.toString());
Weightings weightings = new Weightings();
weightings.getWeightings().addAll((Collection<? extends Weighting>) webTarget.path("rest").path("report").path("loadWeightingByPlate").
request().accept(MediaType.APPLICATION_XML).post(javax.ws.rs.client.Entity.form(formData), Weightings.class));
and this is my web Service :
#Path("/report")
public class WeightingRESTfulService {
#POST
#Path("/loadWeightingByPlate")
#Produces(MediaType.APPLICATION_XML)
#Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Weightings LoadWeightingInSpecTimeInSpecPlate(
#FormParam("plate") String plate,
#FormParam("startTime") String _startTime,
#FormParam("endTime") String _endTime,
#Context HttpServletRequest req) {
Long startTime = new Long(_startTime);
Long endTime = new Long(_endTime);
try {
Weightings weightings = new Weightings();
weightings.getWeightings().addAll(Weighting.LoadWeightingInSpecTimeInSpecPlate(startTime, endTime, plate));
System.out.println("no error");
return weightings;
} catch (Exception ex) {
System.out.println("Exception = " + ex);
return null;
}
}
}
can any one help me to use this web Service ?
there is some warning :
21-Aug-2015 23:18:11.797 WARNING [http-nio-8084-exec-123] org.glassfish.jersey.servlet.WebComponent.filterFormParameters A servlet request to the URI http://localhost:8084/fsc-access/rest/report/loadWeightingByPlate contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using #FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.
and there is som exeprions :
Exception in thread "C3P0PooledConnectionPoolManager[identityToken->1hge1379bmmvkmpse6n4w|7936e088]-AdminTaskTimer" java.lang.IllegalStateException: Can't overwrite cause with java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
at java.lang.Throwable.initCause(Throwable.java:457)
at org.apache.catalina.loader.WebappClassLoader.checkStateForClassLoading(WebappClassLoader.java:1335)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1216)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1177)
at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:1040)
at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1507)
at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1477)
at com.mchange.v2.resourcepool.BasicResourcePool.cullExpired(BasicResourcePool.java:1565)
at com.mchange.v2.resourcepool.BasicResourcePool.access$1900(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResourcePool.java:2089)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.ClassNotFoundException
at org.apache.catalina.loader.WebappClassLoader.checkStateForClassLoading(WebappClassLoader.java:1334)
... 10 more
Exception in thread "C3P0PooledConnectionPoolManager[identityToken->1hge1379bmmw228sz1sso|53826b99]-AdminTaskTimer" java.lang.IllegalStateException: Can't overwrite cause with java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
at java.lang.Throwable.initCause(Throwable.java:457)
at org.apache.catalina.loader.WebappClassLoader.checkStateForClassLoading(WebappClassLoader.java:1335)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1216)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1177)
at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:1040)
at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1507)
at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1477)
at com.mchange.v2.resourcepool.BasicResourcePool.cullExpired(BasicResourcePool.java:1565)
at com.mchange.v2.resourcepool.BasicResourcePool.access$1900(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResourcePool.java:2089)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.ClassNotFoundException
at org.apache.catalina.loader.WebappClassLoader.checkStateForClassLoading(WebappClassLoader.java:1334)
... 10 more
loggingfilter :
22-Aug-2015 00:32:32.969 INFO [http-nio-8084-exec-37] org.glassfish.jersey.filter.LoggingFilter.log 1 * Sending client request on thread http-nio-8084-exec-37
1 > POST http://localhost:8084/fsc-access/rest/report/loadWeightingByPlate
1 > Accept: application/xml
1 > Content-Type: application/x-www-form-urlencoded
22-Aug-2015 00:32:33.015 INFO [http-nio-8084-exec-37] org.glassfish.jersey.filter.LoggingFilter.log 2 * Client response received on thread http-nio-8084-exec-37
2 < 200
2 < Content-Length: 1026
2 < Content-Type: application/xml
2 < Date: Fri, 21 Aug 2015 19:54:48 GMT
2 < Server: Apache-Coyote/1.1
Your resource is returning an instance of Weightings, so you just need to cast it, you don't need to do the addAll()
Weightings weightings = new Weightings();
weightings.getWeightings().addAll((Collection<? extends Weighting>) webTarget.path("rest").path("report").path("loadWeightingByPlate").
request().accept(MediaType.APPLICATION_XML).post(javax.ws.rs.client.Entity.form(formData), Weightings.class));
Should be:
Weightings weightings = (Weightings) webTarget.path("rest").path("report").path("loadWeightingByPlate").
request().accept(MediaType.APPLICATION_XML).post(javax.ws.rs.client.Entity.form(formData), Weightings.class));
It won't fix your 400 exception, but you'll get a ClassCastException without it.
Implementing gcm third party server, we decided to use http integration and followed google instructions.
They provide an implementation of the integration here.
We used it and sent notifications to 500 000 users using java tasks to be more effective (we need to notify our users as quick as possible).
We were surprised because http request to GCM servers could take sometimes more than 15 sec. We set log in gcm-server source and find out this issue.
Code with custom log:
public MulticastResult sendNoRetry(Message message, List<String> registrationIds) throws IOException {
if (nonNull(registrationIds).isEmpty()) {
throw new IllegalArgumentException("registrationIds cannot be empty");
}
Date startDate = new Date();
Map<Object, Object> jsonRequest = new HashMap<Object, Object>();
setJsonField(jsonRequest, PARAM_TIME_TO_LIVE, message.getTimeToLive());
setJsonField(jsonRequest, PARAM_COLLAPSE_KEY, message.getCollapseKey());
setJsonField(jsonRequest, PARAM_RESTRICTED_PACKAGE_NAME, message.getRestrictedPackageName());
setJsonField(jsonRequest, PARAM_DELAY_WHILE_IDLE, message.isDelayWhileIdle());
setJsonField(jsonRequest, PARAM_DRY_RUN, message.isDryRun());
jsonRequest.put(JSON_REGISTRATION_IDS, registrationIds);
Map<String, String> payload = message.getData();
if (!payload.isEmpty()) {
jsonRequest.put(JSON_PAYLOAD, payload);
}
String requestBody = JSONValue.toJSONString(jsonRequest);
log.debug("JSON request: " + requestBody);
HttpURLConnection conn;
int status;
Date beforeHttpRequest = new Date();
try {
conn = post(GCM_SEND_ENDPOINT, "application/json", requestBody);
status = conn.getResponseCode();
} catch (IOException e) {
log.error("IOException posting to GCM", e);
return null;
}
Date afterHttpRequest = new Date();
String responseBody;
if (status != 200) {
try {
responseBody = getAndClose(conn.getErrorStream());
log.debug("JSON error response: " + responseBody);
} catch (IOException e) {
// ignore the exception since it will thrown an
// InvalidRequestException
// anyways
responseBody = "N/A";
log.error("Exception reading response: ", e);
}
throw new InvalidRequestException(status, responseBody);
}
try {
responseBody = getAndClose(conn.getInputStream());
} catch (IOException e) {
log.error("IOException reading response", e);
return null;
}
log.debug("JSON response: " + responseBody);
JSONParser parser = new JSONParser();
JSONObject jsonResponse;
try {
jsonResponse = (JSONObject) parser.parse(responseBody);
int success = getNumber(jsonResponse, JSON_SUCCESS).intValue();
int failure = getNumber(jsonResponse, JSON_FAILURE).intValue();
int canonicalIds = getNumber(jsonResponse, JSON_CANONICAL_IDS).intValue();
long multicastId = getNumber(jsonResponse, JSON_MULTICAST_ID).longValue();
MulticastResult.Builder builder = new MulticastResult.Builder(success, failure, canonicalIds, multicastId);
#SuppressWarnings("unchecked")
List<Map<String, Object>> results = (List<Map<String, Object>>) jsonResponse.get(JSON_RESULTS);
if (results != null) {
for (Map<String, Object> jsonResult : results) {
String messageId = (String) jsonResult.get(JSON_MESSAGE_ID);
String canonicalRegId = (String) jsonResult.get(TOKEN_CANONICAL_REG_ID);
String error = (String) jsonResult.get(JSON_ERROR);
Result result = new Result.Builder().messageId(messageId).canonicalRegistrationId(canonicalRegId).errorCode(error)
.build();
builder.addResult(result);
}
}
MulticastResult multicastResult = builder.build();
log.info("Http Request takes : "
+ (afterHttpRequest.getTime() - beforeHttpRequest.getTime()) / 1000 + " sec");
return multicastResult;
} catch (ParseException e) {
throw newIoException(responseBody, e);
} catch (CustomParserException e) {
throw newIoException(responseBody, e);
}
}
and the log:
2014-11-12 13:01:54,660 INFO executor-37 Sender:466 - Http Request takes : 4 sec
2014-11-12 13:01:57,383 INFO executor-49 Sender:466 - Http Request takes : 6 sec
2014-11-12 13:01:57,702 INFO executor-31 Sender:466 - Http Request takes : 6 sec
2014-11-12 13:01:58,565 INFO executor-42 Sender:466 - Http Request takes : 9 sec
2014-11-12 13:01:58,602 INFO executor-39 Sender:466 - Http Request takes : 7 sec
2014-11-12 13:01:59,477 INFO executor-45 Sender:466 - Http Request takes : 10 sec
2014-11-12 13:02:00,876 INFO executor-36 Sender:466 - Http Request takes : 20 sec
2014-11-12 13:02:01,018 INFO executor-43 Sender:466 - Http Request takes : 3 sec
2014-11-12 13:02:01,055 INFO executor-40 Sender:466 - Http Request takes : 6 sec
2014-11-12 13:02:02,440 INFO executor-41 Sender:466 - Http Request takes : 11 sec
2014-11-12 13:02:02,846 INFO executor-50 Sender:466 - Http Request takes : 5 sec
2014-11-12 13:02:03,135 INFO executor-47 Sender:466 - Http Request takes : 4 sec
2014-11-12 13:02:03,237 INFO executor-46 Sender:466 - Http Request takes : 4 sec
We tried it from different servers, and it is not a connectivity issue.
¿Someone may know why it takes so much time for a simple http request?
Everything ok in this code... it was as simple network issue.
I believed my server had 10 Mbytes/s upload rate, and it may be true, but in fact, it is physically far from google servers so upload rate was the bottleneck.
i have implemented the Subscriptions flow using the java library jsontoken, but am getting an error 500. happen in the sandox and production. any idea why it is?
this is the error :
POST https://checkout.google.com/inapp/api/v1/purchase_options 500 (Internal Server Error)
this is the code:
Calendar cal = Calendar.getInstance();
HmacSHA256Signer signer = new HmacSHA256Signer(ISSUER, null, SIGNING_KEY.getBytes());
JsonToken token = new JsonToken(signer);
token.setAudience("Google");
token.setParam("typ", "google/payments/inapp/subscription/v1");
token.setIssuedAt(new Instant(cal.getTimeInMillis()));
token.setExpiration(new Instant(cal.getTimeInMillis() + 60000L));
long prorated =cal.getTimeInMillis() + 2592000000L;
JsonObject request = new JsonObject();
request.addProperty("name", "Piece of Cake");
request.addProperty("description", "Virtual chocolate cake to fill your virtual tummy");
request.addProperty("sellerData", "user_id:1224245,offer_code:3098576987,affiliate:aksdfbovu9j");
request.addProperty("initialPayment", "{\"price\" : \"1.49\",\"currencyCode\" : \"USD\",\"paymentType\" : \"prorated\",}");
request.addProperty("recurrence", "{\"price\" : \"4.99\",\"currencyCode\" : \"USD\",\"startTime\" : \""+prorated+"\",\"frequency\" : \"monthly\",\"numRecurrences\" : \"12\",}");
JsonObject payload = token.getPayloadAsJsonObject();
payload.add("request", request);
token.serializeAndSign();