PUT request and 405 Method not allowed

65 views
Skip to first unread message

Carmelo Taverniti

unread,
Oct 2, 2013, 1:24:48 PM10/2/13
to codenameone...@googlegroups.com
I try to make an HTTP PUT request but I receive "405 Method not allowed". 

The request is simple, ed il web service is operating like is visible in the screenshot.




The next, is the code that I use:
 public String purchaseConfirmation() {
       
String jsonString = "{\"cliente\":.....}";

       
final String b = jsonString;
       
ConnectionRequest cn = new ConnectionRequest() {
           
@Override
           
protected void buildRequestBody(OutputStream os)throws IOException {
                os
.write(b.getBytes("UTF-8"));
           
}
       
};
        cn
.setPost(true);
        cn
.setHttpMethod("PUT");
        cn
.setUrl(URL_APP + URL_SUFFISSO_CONFORDINE);
        cn
.setContentType("application/json");
       
NetworkManager.getInstance().addToQueueAndWait(cn);
       
byte[] a = cn.getResponseData();
       
String codiceConfermaOrdine = null;
       
try {
            codiceConfermaOrdine
= new String(a, "US-ASCII");
           
......
       
} catch (UnsupportedEncodingException ex) {
           
       
}
   
}


Why? Where is the mistake? someone can help me?



Shai Almog

unread,
Oct 2, 2013, 4:16:37 PM10/2/13
to codenameone...@googlegroups.com
Hi,
your code seems fine. 405 is a server error which means the server doesn't support the put method for the given URL. I suggest you verify the URL, port number and method.

Carmelo Taverniti

unread,
Oct 2, 2013, 5:11:57 PM10/2/13
to codenameone...@googlegroups.com
It's amazing I have lost a lot of time...I have checked many time the URL but I did seen 'O' where there had to be 'o' .. the mistake is a char uppercase, that had to be lowercase in the URL string

Still thanks Anyway for the fast support :D
Reply all
Reply to author
Forward
0 new messages