I'm trying to send a HTTP DELETE request to a RESTful Django web service from my iOS app. I use AFNetworking 2.0 (2.4).
After analysing the AFHTTPREquestOperation
in the success block of my API call, i found that the body of the request is nil. The parameters URL encoded and sent in the URL.
<AFHTTPRequestOperation: 0x10c587940,
state: isFinished,
cancelled: NO
request: <NSMutableURLRequest: 0x10c521ab0> {
URL: https://anURL.com/connections?data%5Bconnections%5D%5B%5D%5Bid%5D=106 },
response: <NSHTTPURLResponse: 0x10c5c7590> {
URL: anURL.com/
connections?data%5Bconnections%5D%5B%5D%5Bid%5D=106
}
{ status code: 200, headers {
Connection = "Keep-Alive";
"Content-Type" = "application/json";
Date = "Tue, 05 Aug 2014 14:07:53 GMT";
"Keep-Alive" = "timeout=5, max=100";
Server = "Apache/2.4.7 (Ubuntu)";
"Transfer-Encoding" = Identity;
} }>
Now I wonder if it is possible to send the parameters in the body of the request, as done with HTTP POST instead of sending them in the URL. Is that possible?
How to do it using AFNetworking?
How i send atm:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager DELETE:host_url parameters:params success:success failure:failure];
The body i want to send(its whats in the "params" parameter above):
{
"data": {
"connections": [
{
"id": 92
},
{
"id": 91
}
]
}
}