Reputation: 1179
The same question asked here but I want to make a request with following structure.
"method": "post",
"url": parserApiUrl,
"data": {
"url": s3BaseUrl + imageKey
},
"headers": {
"x-api-key": "sdsdasdwdw"
}
Upvotes: 1
Views: 7586
Reputation: 1179
I Found a solution for this by this steps
urlConnection = (HttpURLConnection) url
.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("Content-Type", "application/json");
urlConnection.setRequestProperty("x-api-key", x_api);
urlConnection.setRequestProperty("Accept", "application/json");
String datajson = "{\"file\": \""+imageString.trim()+"\"}";
Log.e("data","json:"+datajson);
OutputStream os = urlConnection.getOutputStream();
os.write(datajson.getBytes("UTF-8"));
os.close();
Upvotes: 7