Rest post method

#1

hello,

i’m trying to do some Rest http with post methode but it seem the api don’t work, code im using is very simple .

i create the rest object and with Resty().json(uri,content) i’m trying to do Post request, code bellow :
Resty r = new Resty();
JSONObject msg = new JSONObject();
msg.put(“applicationKey”.toString(), “###################”).put("“textInput”",“10”);
AbstractContent cnt = Resty.content(msg.toString());
System.out.println(msg);
name = r.json("http://webdemoapi.myscript.com/api/v3.0/recognition/rest/text/doSimpleRecognition.json?",cnt);

but it don’t work and i have the error bellow :

sun.net.www.protocol.http.HttpURLConnection:http://webdemoapi.myscript.com/api/v3.0/recognition/rest/text/doSimpleRecognition.json
responseCode
400
{“result”:{“message”:“Required String parameter ‘applicationKey’ is not present”}}

#2

Hi @ghassane_elkebir,

The content will be the body of your request, if your webserver is expecting parameters you should put them in your URI:

Resty r = new Resty();
name = r.json("http://webdemoapi.myscript.com/api/v3.0/recognition/rest/text/doSimpleRecognition.json?applicationKey=###################&textInput=10");

Regards,