I am getting response in Postman with same url and token. I am sure that there is issue in Passing token with Post Request.
Can anyone help me?
I am getting response in Postman with same url and token. I am sure that there is issue in Passing token with Post Request.
Can anyone help me?
May this code help you to post a request with token as header.!
public HttpResponse makeRequest(String uri, String json) {
try {
HttpClient httpclient = new DefaultHttpClient();
HttpClientStack.HttpPatch httpPatch = new HttpClientStack.HttpPatch(uri); // create new httpGet object
httpPatch.setHeader("Authorization", getAccessToken());
httpPatch.setEntity(new StringEntity(json));
httpPatch.setHeader("Content-Type", "application/json; charset=utf-8");
HttpResponse response = httpclient.execute(httpPatch);
HttpEntity entity = response.getEntity();
resCoupon = EntityUtils.toString(entity);
Log.d("requestride", resCoupon);
return new DefaultHttpClient().execute(httpPatch);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}