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
wiki
Comments
Post a Comment