android - Okhttp Put method returning 'Method Not Allowed' -
i attempting call put method on server using okhttp android application.
this api method signature:
public void put(int userid, string regid) { }
this android code call above method...
private boolean sendgcmregidtoserver(string registrationid, integer userid) throws ioexception { httpurl url = new httpurl.builder() .scheme("http") .host(serverapihost) .addpathsegment("appdashboard") .addpathsegment("api") .addpathsegment("gcm/") .build(); mediatype json = mediatype.parse("application/json; charset=utf-8"); string json = "{'userid':" + userid + "," + "'regid':'" + registrationid + "'" + "}"; requestbody requestbody = requestbody.create(json, json); request request = new request.builder() .url(url) .put(requestbody) .build(); //this should post data server response response = client.newcall(request).execute(); if(response.code() == 400) return false; return true; }
now problem getting error code 405 in response saying method not allowed, cannot see problem because can succesfully call method using postman on server below:
http://localhost/appdashboard/api/gcm?userid=5®id=123
i'm thinking may have integer or string being passed incorrectly in json string cannot life of see why isn't working...
any appreciation thanks...
i had same problem , server returning 405 . after search realized configuration problem on iis not let put requests. there no problem in android code , should config server let kind of requests. see this , this , this
Comments
Post a Comment