Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.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 AFN网络序列化响应错误_Ios - Fatal编程技术网

Ios AFN网络序列化响应错误

Ios AFN网络序列化响应错误,ios,Ios,我正在使用AFNetworking 3.0版来处理POST请求。 当我运行代码时,我得到一个错误,上面写着:在这里输入代码 2016-01-26 16:48:50.181 Voluntree[3590:1749083] In order to validate a domain name for self signed certificates, you MUST use pinning. 2016-01-26 16:48:50.905 Voluntree[3590:1748745] Error

我正在使用AFNetworking 3.0版来处理POST请求。 当我运行代码时,我得到一个错误,上面写着:在这里输入代码

2016-01-26 16:48:50.181 Voluntree[3590:1749083] In order to validate a domain name for self signed certificates, you MUST use pinning.
2016-01-26 16:48:50.905 Voluntree[3590:1748745] Error: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/plain" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x13deb83d0> { URL: https://voluntree.imrapid.io/signup_by_email } { status code: 200, headers {
    "Access-Control-Allow-Headers" = "Origin, X-Requested-With, Content-Type, Accept";
    "Access-Control-Allow-Methods" = "POST, GET, OPTIONS, PUT, DELETE, HEAD";
    "Access-Control-Allow-Origin" = "*";
    Connection = "keep-alive";
    "Content-Length" = 4;
    "Content-Type" = "text/plain";
    Date = "Tue, 26 Jan 2016 14:48:50 GMT";
    Server = Cowboy;
    Via = "1.1 vegur";
    "X-Powered-By" = Express;
} }, NSErrorFailingURLKey=https://voluntree.imrapid.io/signup_by_email, com.alamofire.serialization.response.error.data=<32343634>, NSLocalizedDescription=Request failed: unacceptable content-type: text/plain}
2016-01-26 16:48:50.181 Voluntree[3590:1749083]要验证自签名证书的域名,必须使用固定。
2016-01-26 16:48:50.905 Voluntree[3590:1748745]错误:错误域=com.alamofire.Error.serialization.response代码=-1016“请求失败:不可接受的内容类型:text/plain”UserInfo={com.alamofire.serialization.response.Error.response={URL:https://voluntree.imrapid.io/signup_by_email }{状态代码:200,标题{
“访问控制允许标头”=“来源,X请求,内容类型,接受”;
“访问控制允许方法”=“POST、GET、OPTIONS、PUT、DELETE、HEAD”;
“访问控制允许来源”=“*”;
连接=“保持活动”;
“内容长度”=4;
“内容类型”=“文本/普通”;
日期=“2016年1月26日星期二14:48:50 GMT”;
服务器=牛仔;
Via=“1.1织女星”;
“X-Powered-By”=快车;
}},NSErrorFailingURLKey=https://voluntree.imrapid.io/signup_by_email,com.alamofire.serialization.response.error.data=,NSLocalizedDescription=请求失败:不可接受的内容类型:text/plain}

您应该将标题“Content Type”值更改为application/www-x-form-urlencoded,而不是现在的“text/plain”

对于application/x-www-form-urlencoded,发送到服务器的HTTP消息主体本质上是一个巨大的查询字符串——名称/值对由符号和(&)分隔,名称与值由等号(=)分隔。这方面的一个例子是:


MyVariableOne=ValueOne&MyVariableTwo=ValueTwo

您应该将标题“内容类型”值更改为application/www-x-form-urlencoded,而不是现在的“text/plain”

对于application/x-www-form-urlencoded,发送到服务器的HTTP消息主体本质上是一个巨大的查询字符串——名称/值对由符号和(&)分隔,名称与值由等号(=)分隔。这方面的一个例子是:


MyVariableOne=ValueOne&MyVariableTwo=ValueTwo

您是否也可以发布您的Objective-C代码,以便我们查看代码中的设置?当标题向您显示错误时,您似乎对内容类型有问题-将其更改为application/www-x-form-urlencodedI刚刚将acceptableContentTypes更改为application/json。对我来说很好。谢谢您是否也可以发布您的Objective-C代码,以便我们查看代码中的设置?当标题向您显示错误时,看起来您的内容类型有问题-将其更改为application/www-x-form-urlencodedI刚刚将acceptableContentTypes更改为application/json。对我来说很好。谢谢出于某种原因,现在当我将内容类型设置为“application/www-x-form-urlencoded”或“application/json”时,它告诉我:不可接受的内容类型:application/json…@ItayPincas出于某种原因,您应该以内容类型发送application/www-x-form-urlencoded,现在,当我将内容类型设置为“application/www-x-form-urlencoded”或“application/json”时,它告诉我:不可接受的内容类型:application/json…@ItayPincas您应该以内容类型发送application/www-x-form-urlencoded