5

I need to how I can send an http delete request, I've implemented the code below

- (void) deleteSyncRequestWithURL:(NSString *) url
{
    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];

    [request setURL:[NSURL URLWithString:url]];
    [request setHTTPMethod:@"DELETE"];  
    _connection = [[NSURLConnection connectionWithRequest:request delegate:self] retain];    
}

But I've got a 404 status.

Does anyone know what I'm missing??

P.S: I'm using xcode 3.2.3, simulator 4.0

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
UnSaid
  • 121
  • 1
  • 8

1 Answers1

1

It looks as if your Delete request is being issued correctly, but the server is choosing to respond with a 404 - document not found error.

Do you have control over the server application too? Are you sure the server has a resource at that URL that responds to a Delete request?

If you are suspicious of the Delete request being made - I would use an HTTP proxy to examine the request directly, you can then compare to your other client. I would use Wireshark (on the Mac). If the other client is on a PC, you could use Fiddler, which is excellent.

iandotkelly
  • 9,024
  • 8
  • 48
  • 67
  • I found the error I'm using h t t p://www .restOfMyUrl I should use h t t p://restOfMyUrl, it's working now, thx :)) – UnSaid Nov 30 '11 at 15:05
  • Well as Marc B and I said - do you have a resource at the URL? The answer was no because your URL was wrong. I find HTTP proxy tools like Wireshark and Fiddler to be essential tools when writing software that uses HTTP. Using such tools, you could easily see that the application had been sent to the wrong URL. – iandotkelly Nov 30 '11 at 15:35