我需要手动创建请求,而不是使用AFNetworking。
NSString *baseURL = @"http://pl-dev2.railwaymen.org:4213/";
NSString *URLString = [NSString stringWithFormat:@"events/%@", identifier];
NSURL *url = [NSURL URLWithString:URLString relativeToURL:baseURL];
//final URL: http://pl-dev2.railwaymen.org:4213/events/6572673456
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"PUT"];
现在我想发送一些参数:
NSDictionary *params = @{
"a": "valueA",
"b": 23,
"c": [NSNull null],
"d": ["lisbona", "warsaw", "ny"],
"e": UIImageJPEGRepresentation(image, 1)
};
我该怎么做?
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:nil error:&error];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
[request setHTTPBody:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
不幸的是无效
如何查看最终请求网址?
http://pl-dev2.railwaymen.org:4213/events/6572673456?a=valueA&b=23&c=&d[]=lisbona&d[]=warsaw&d[]=ny&e=
该查询的哪一部分是httpBody?每次?
之后。
参数c
和e
怎么样?
工作原理?