我正在尝试使用 PUT 方法通过 NSUrlConnection 更新数据。为了添加数据,我使用的是 POST 方法,它工作正常,但同时 PUT 不工作。
NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"%@update/%@?userId=%@",xapp.urlString,[dict valueForKey:@"id"],[profileDict valueForKey:@"id"]] ];
NSError *error;
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"PUT"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:jsonData];
updateHiveConnection=[NSURLConnection connectionWithRequest:request delegate:self];
我将 JSON 数据发送到这个 api {"id":3,"active":false} 之后我收到错误
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (No value.) UserInfo=0x1fb456f0 {NSDebugDescription=No value.}
任何帮助将不胜感激谢谢