我不确定如何实现与此curl请求等效的post请求:
curl -F=@file.json https://www.example.com/?id=some_id
我尝试创建一个等同于我的json的NSDictionary,
jsondata = [NSJSONSerialization dataWithJSONObject:dict
options:NSJSONWritingPrettyPrinted
error:&error];
NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.example.com/?id=some_id"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:120.0];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:jsondata];
但有些事情是错误的,因为它不起作用。如果你知道问题是什么,请帮忙。