Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting 405 error in POST NSMutableURLRequest
    primarykey
    data
    text
    <p>I have an app which communicates with the server. I need to send a message id to the server. I am using NSMutableURL Request. However, I am getting a 405 error while submitting the request. </p> <p>Below is the code</p> <pre><code>messageid=@"1234"; NSURL *aUrl = [NSURL URLWithString:@"http://myexample.com:8080/Padua/rest/messages/messagetodelete"]; NSMutableURLRequest *deleterequest = [NSMutableURLRequest requestWithURL:aUrl cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; NSURLConnection *connection= [[NSURLConnection alloc] initWithRequest:deleterequest delegate:self]; [deleterequest setHTTPMethod:@"POST"]; [deleterequest setValue:[NSString stringWithFormat:@"%d", messageid.length] forHTTPHeaderField:@"Content-Length"]; [deleterequest setValue:@"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField:@"Content-Type"]; NSString *postString = messageid; [deleterequest setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]]; [connection start]; </code></pre> <p>The server side code is below</p> <pre><code>@POST @Consumes("text/plain") @Path("/messagetodelete") public void messageToDelete(String messageid){ //code to delete the message in MongoDB System.out.println("R u here for iphone??"); } </code></pre> <p>Is the code in the client end (iPhone ) correct. The POST consumes a plain text. I believe this is where I am going wrong.</p> <p>Could anyone please guide me as how to achieve it and make the NSMutableURLRequest accepted by the server?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload