卷曲文件上传-F在目标c中发布请求

时间:2017-05-10 06:49:28

标签: ios objective-c curl post

我不确定如何实现与此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];

但有些事情是错误的,因为它不起作用。如果你知道问题是什么,请帮忙。

0 个答案:

没有答案