header - Getting code 200 on Postman but 403 on Android using HttpUrlConnection -




i using httpurlconnection fire put request in android code. api works on postman , other rest giving 200 success code failing in android code. please check code below , let me know making error.

    try {         url url = new url(myurl);         httpurlconnection connection = (httpurlconnection) url.openconnection();         connection.setrequestmethod("put");         connection.setdooutput(true);         connection.setrequestproperty("content-type", "application/json");         connection.setrequestproperty("accept", "application/json");         connection.setrequestproperty("cookie", "jsessionid=" + mnetworkmodel.sessionid() + "; x-csrf-token=" + mnetworkmodel.csrftoken());         connection.setrequestproperty("jsessionid", mnetworkmodel.sessionid());         connection.setrequestproperty("x-csrf-token", urlencoder.encode(mnetworkmodel.csrftoken(), "utf-8"));         outputstreamwriter osw = new outputstreamwriter(connection.getoutputstream());         osw.write("");         osw.flush();         osw.close();         system.err.println(connection.getresponsecode());          if(connection.getresponsecode()==200)         {             outcome = true;         }         else         {             outcome = false;         }     }     catch (exception e){         e.printstacktrace();     } 

please check postman request below too

postman screen shot

enter image description here





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -