Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 数据未在web服务上发布_Ios - Fatal编程技术网

Ios 数据未在web服务上发布

Ios 数据未在web服务上发布,ios,Ios,我想将字典发布到Web服务。但它并没有得到post。每次我发布数据时,我都会从web服务中得到错误消息。我也尝试了不同的方法使用AFNetworking,但使用这种方法我得到了406个错误 你可以看到另一个问题 由NSData*body=[nsKeyedArchivedDataWithRootObject:params]生成的您发布的正文是NSPropertyListBinaryFormat_v1_0,它是二进制序列化数据 Http服务器无法识别它。您可以通过JSON发布 NSData *bod

我想将字典发布到Web服务。但它并没有得到post。每次我发布数据时,我都会从web服务中得到错误消息。我也尝试了不同的方法使用
AFNetworking
,但使用这种方法我得到了406个错误

你可以看到另一个问题


NSData*body=[nsKeyedArchivedDataWithRootObject:params]生成的您发布的正文是NSPropertyListBinaryFormat_v1_0,它是二进制序列化数据

Http服务器无法识别它。您可以通过JSON发布

NSData *body = [NSJSONSerialization dataWithJSONObject:"NSDictionary variable name"
                                           options:NSJSONWritingPrettyPrinted
                                             error:&error];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://web.info/ministore/store-commerce/user/register"]];
[request setHTTPBody:body];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-type"];
[request setValue:[NSString stringWithFormat:@"%d", [body length]] forHTTPHeaderField:@"Content-Length"];
可能重复的
NSData *body = [NSJSONSerialization dataWithJSONObject:"NSDictionary variable name"
                                           options:NSJSONWritingPrettyPrinted
                                             error:&error];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://web.info/ministore/store-commerce/user/register"]];
[request setHTTPBody:body];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-type"];
[request setValue:[NSString stringWithFormat:@"%d", [body length]] forHTTPHeaderField:@"Content-Length"];