Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Android OAuth 1.0 post request

Risk:

I am new to android and I am using O-Authentication 1.0 in my Code. Get request is working but post request is not working in my code. When I check in postman I get response but not getting request in the code. Here is my code : protected String doInBackground(String... params) {


try {
URL url = new URL(params[0]);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setDoInput(true);
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestProperty("Content-Type", "application/json");
httpURLConnection.setRequestMethod("POST");


// Send the post body
if (this.postData != null) {
OutputStreamWriter writer = new OutputStreamWriter(httpURLConnection.getOutputStream());
writer.write(postData.toString());
writer.flush();
}

int statusCode = httpURLConnection.getResponseCode();

if (statusCode == 200) {

InputStream inputStream = new BufferedInputStream(httpURLConnection.getInputStream());

} else {
// Status code is not 200
// Do something to handle the error
}

} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}

Thanks in advance.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Android OAuth 1.0 post request

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×