获取请求失败:发布参数时不可接受(406) [英] Getting Request failed: unacceptable (406) when posting parameters

查看:674
本文介绍了获取请求失败:发布参数时不可接受(406)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将参数发布到Web服务中。使用下面的代码。并且我收到请求失败:无法接受(406)错误。我不确定即时消息发布是否正确。



我尝试发布数据使用POSTMAN chrome应用程序使用键和值对进行处理,并且在那儿工作正常。此处不建议.i首次使用Afnetworking

  [parameter setValue:self.txtUserName forKey:@ name]; 
[params setValue:self.txtEmail forKey:@ mail];
[params setValue:self .txtPass forKey:@ conf_mail];
[param setValue:self.txtPass2 forKey:@ pass];


AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
[经理POST:@ http://charlie.indivar.info/ministore/store-commerce/user/register
参数:params
成功:^(AFHTTPRequestOperation * operation,id responseObject){

NSLog(@ JSON:%@,responseObject);
}失败:^(AFHTTPRequestOperation * operation,NSError * error){
NSL og(@错误:%@,错误);

UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@错误检索数据
消息:[错误localizedDescription]
委托人:无
cancelButtonTitle:@ OK
otherButtonTitles:nil];
[alertView show];

}];

下面是控制台日志

 错误:错误域= com.alamofire.error.serialization.response代码= -1011请求失败:不可接受(406) UserInfo = 0x8deb400 {com.alamofire.serialization.response.error.response =< NSHTTPURLResponse:0x8ddddf0> {URL:http://website.com/ministore/store-commerce/user/register} {状态代码:406,标头{
Cache-Control =无缓存,必须重新验证,后置检查= 0,预检查= 0;
Connection =保持活动;
Content-Length = 396;
Content-Type =应用程序/ json;
Date = 2014年10月10日,星期五,格林尼治标准时间;
Etag = \ 1412924800\;
Expires =格林尼治标准时间1978年11月19日星期日;
Keep-Alive =超时= 5,最大= 100;
Last-Modified =星期五,2014年10月10日07:06:40 +0000;
服务器= Apache;
Set-Cookie = SESSd5cd87b70f9ea9019d306d6f4e440b74 = 5lpY8-PvQYRM5IBWiGk33EeXsucAJCBZQSce7vRBhEY; expires = Sun,02-Nov-2014 10:40:01 GMT; On = ;; domain = /; domain =
Vary =接受;
X-Drupal-Cache = MISS;
X-Powered-By = PHP / 5.3.10-1ubuntu3.14;
}},NSErrorFailingURLKey = http://website.com/ministore/store-commerce/user/register,NSLocalizedDescription=请求失败:不可接受(406),com.alamofire.serialization.response.error.data =




0a7b2273 74617475 73223a22 30222c22 64617461 223a7b22 6e616d65 223a2255 7365726e 616d6520 63616e6e
6f742062 65206c6f 6e676572 20746861 6e203630 20636861 72616374
65727320 62757420 69732063 75727265 6e746c79 20323031 20636861
72616374 65727320 6c6f6e67 2e222c22 6d61696c 223a2254 68652065
2d6d6169 6c206164 64726573 7320266c 743b5549 54657874 4669656c
643a2030 78386462 63306230 3b206672 616d6520 3d202835 37203135
343b2031 35332033 30293b20 74657874 203d2026 23303339 3b646565
70616b73 6f6f6440 64656570 616b2e63 6f6d2623 3033393b 3b20636c
69707354 6f426f75 6e647320 3d205945 533b206f 70617175 65203d20
4e4f3b20 6175746f 72657369 7a65203d 20524d2b 424d3b20 67657374
75726552 656 36f67 6e697a65 7273203d 20266c74 3b4e5341 72726179
3a203078 38663665 38613026 67743b3b 206c6179 6572203d 20266c74
3b43414c 61796572 3a203078 38646165 65653026 67743b26 67743b20
6973206e 6f742076 616c6964 2e227d7d>}



解决方案


如果Web服务器检测到要返回的数据不为客户端接受
,则返回包含406错误
代码的标头。该错误在Web浏览器中很少发生,因为大多数浏览器都会接受从Web服务器返回的所有数据。


无法识别您正在移动等...



http://www.checkupdown.com/status/E406.html


i am posting the parameter in the web-service. using the below code. and i am getting the "Request failed: unacceptable (406) Error .I am not sure is im posting it right .

I tried posting the data using their key and value pair using POSTMAN chrome app . and it is working fine there.Not here pls suggest .i am using Afnetworking for the first time

[params setValue:self.txtUserName forKey:@"name"];
[params setValue:self.txtEmail forKey:@"mail"];
[params setValue:self.txtPass forKey:@"conf_mail"];
[params setValue:self.txtPass2 forKey:@"pass"];


AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager POST:@"http://charlie.indivar.info/ministore/store-commerce/user/register"
   parameters:params
      success:^(AFHTTPRequestOperation *operation, id responseObject) {

          NSLog(@"JSON: %@", responseObject);
      } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          NSLog(@"Error: %@", error);

          UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error Retrieving Data"
                                                              message:[error localizedDescription]
                                                             delegate:nil
                                                    cancelButtonTitle:@"Ok"
                                                    otherButtonTitles:nil];
          [alertView show];

      }];

Below is the console log

Error: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: unacceptable (406)" UserInfo=0x8deb400 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x8ddddf0> { URL: http://website.com/ministore/store-commerce/user/register } { status code: 406, headers {
"Cache-Control" = "no-cache, must-revalidate, post-check=0, pre-check=0";
Connection = "Keep-Alive";
"Content-Length" = 396;
"Content-Type" = "application/json";
Date = "Fri, 10 Oct 2014 07:06:40 GMT";
Etag = "\"1412924800\"";
Expires = "Sun, 19 Nov 1978 05:00:00 GMT";
"Keep-Alive" = "timeout=5, max=100";
"Last-Modified" = "Fri, 10 Oct 2014 07:06:40 +0000";
Server = Apache;
"Set-Cookie" = "SESSd5cd87b70f9ea9019d306d6f4e440b74=5lpY8-PvQYRM5IBWiGk33EeXsucAJCBZQSce7vRBhEY; expires=Sun, 02-Nov-2014 10:40:01 GMT; path=/; domain=website.com; HttpOnly";
Vary = Accept;
"X-Drupal-Cache" = MISS;
"X-Powered-By" = "PHP/5.3.10-1ubuntu3.14";
} }, NSErrorFailingURLKey=http://website.com/ministore/store-commerce/user/register, NSLocalizedDescription=Request failed: unacceptable (406), com.alamofire.serialization.response.error.data=

0a7b2273 74617475 73223a22 30222c22 64617461 223a7b22 6e616d65 223a2255 7365726e 616d6520 63616e6e 6f742062 65206c6f 6e676572 20746861 6e203630 20636861 72616374 65727320 62757420 69732063 75727265 6e746c79 20323031 20636861 72616374 65727320 6c6f6e67 2e222c22 6d61696c 223a2254 68652065 2d6d6169 6c206164 64726573 7320266c 743b5549 54657874 4669656c 643a2030 78386462 63306230 3b206672 616d6520 3d202835 37203135 343b2031 35332033 30293b20 74657874 203d2026 23303339 3b646565 70616b73 6f6f6440 64656570 616b2e63 6f6d2623 3033393b 3b20636c 69707354 6f426f75 6e647320 3d205945 533b206f 70617175 65203d20 4e4f3b20 6175746f 72657369 7a65203d 20524d2b 424d3b20 67657374 75726552 65636f67 6e697a65 7273203d 20266c74 3b4e5341 72726179 3a203078 38663665 38613026 67743b3b 206c6179 6572203d 20266c74 3b43414c 61796572 3a203078 38646165 65653026 67743b26 67743b20 6973206e 6f742076 616c6964 2e227d7d>}

解决方案

If the Web server detects that the data it wants to return is not acceptable to the client, it returns a header containing the 406 error code. This error occurs very infrequently in Web browsers, because most browsers will accept any data returned from the Web server.

Looks like the server is not recognized that you are mobile etc...

http://www.checkupdown.com/status/E406.html

这篇关于获取请求失败:发布参数时不可接受(406)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆