iOS post请求时报错NSLocalizedDescription=Expected status code in (200-299), got 400

用AFNetworking postJSON数据的时候,刚开始提示我//Error Domain=NSURLErrorDomain Code=-1007 "too many HTTP redirects",说是多重定向问题

后来我改了之后又报错//NSLocalizedDescription=Expected status code in (200-299), got 400

解决办法:

NSString *[email protected]"http://api.XXX.com/provider" ;

NSDictionary *jsonObject = @{@"key":@"5dc1203cd89d85c713ef6704d651c7ce",@"userId":@"123456654321"};

AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:pathStr]];

httpClient.parameterEncoding=AFJSONParameterEncoding;

[httpClient registerHTTPOperationClass:[AFJSONRequestOperation class]];

[httpClient setDefaultHeader:@"Accept" value:@"application/json"];

//    NSMutableDictionary *params=[[NSMutableDictionary alloc]init];

//

//    [params setObject:@"5dc1203cd89d85c713ef6704d651c7ce" forKey:@"key"];

//

//    [params setObject:@"123456654321" forKey:@"userId"];

[httpClient postPath:@"accessToken" parameters:jsonObject success:^(AFHTTPRequestOperation *operation, id responseObject) {

NSLog(@"data=====%@",jsonObject);

//NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];

NSLog(@"responseString:%@",operation.responseString);

//NSLog(@"Request Successful, response ‘%@‘", responseStr);

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

NSLog(@"[HTTPClient Error]: %@", error);

}];

时间: 2024-10-19 19:47:25

iOS post请求时报错NSLocalizedDescription=Expected status code in (200-299), got 400的相关文章

AFNetwork 2.0在请求时报错code=-1016 和 3840

在进行网络请求时出现-1016 是因为只支持 text/json,application/json,text/javascript 你可以添加text/html 一劳永逸的方法是 在 AFURLResponseSerialization.h 里面搜索 self.acceptableContentTypes 然后 在里面 添加 @"text/html",@"text/plain" 这样就可以解决-1016的错误了 但是随之而来的是3840错误 Error Domain

android发送get请求时报错

异常信息: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.synology.synologycloud/com.synology.synologycloud.MainActivity}: android.os.NetworkOnMainThreadException 第一次看到这异常,字面意思是说:在主线程中的网络异常.然后我就去了解了下这个异常,先看看官方的说明 public class Netwo

解决Twilio本地Postman请求时报错SSL certificate problem: unable to get local issuer certificate

http://www.shuijingwanwq.com/2018/02/28/2406/ https://curl.haxx.se/docs/caextract.html 编辑 php.ini,修改 ;curl.cainfo = 为 curl.cainfo = “C:\php-7.1.12\extras\ssl\cacert.pem” 原文地址:https://www.cnblogs.com/denghuachengle/p/11682209.html

Laravel消息通知发送邮件 Expected response code 250 but got code "553", with message "553 Mail from must equal authorized use

今天在做项目的时候,使用laravel做消息通知,安装官网教程一步一步做下来,测试的时候报错, Expected response code 250 but got code "553", with message "553 Mail from must equal authorized use 转载请注明(B5教程网)原文链接:http://www.bcty365.com/content-153-5898-1.html 当时.env邮箱配置如下: MAIL_DRIVER=s

安装Python的psutil模块时报错:error: command 'gcc' failed with exit status 1

安装Python的psutil模块: tar zxvf psutil-2.0.0.tar.gz cd psutil-2.0.0 python setup.py install 报错: running install running bdist_egg ...... psutil/_psutil_linux.c:12:20: error: Python.h: No such file or directory In file included from psutil/_psutil_linux.c

IOS问题汇总:2015-1-8 SBJson解析时报错—json文件字符非法

SBJson解析时报错—json文件字符非法 Error Domain=org.brautaset.SBJsonParser.ErrorDomain Code=0 “Illegal start of token [ï]” UserInfo=0x7fd46ad98590 {NSLocalizedDescription=Illegal start of token [ï]} IOS应用在iPhone5和iPhone5s上不能全屏显示,应用画面上下各有1条黑色的解决方案——是因为LaunchScree

安装cx_Oracle时报错:error: command 'gcc' failed with exit status 1

1.安装cx_Oracle 1)下载cx_Oracle,https://pypi.python.org/pypi 2)解压压缩包 3)执行python setup.py install 执行后报错:error: command 'gcc' failed with exit status 1 排查: 1)检查是否安装oracle客户端软件 2)查看当前环境变量中是否配置oracle的相关变量,如echo $ORACLE_HOME 3)如果没有配置需要将oracle环境变量配置到当前用户.bash_

SQL SERVER 2008筛选时报错 无法为该请求检索数据

使用SqlServer2008的筛选功能时报错“无法为该请求检索数据. (Microsoft.SqlServer.Management.Sdk.Sfc)” 如下图: 解决方法: 打上SQL SERVER SP1补丁. 下载地址: http://www.microsoft.com/downloads/zh-cn/details.aspx?FamilyID=66AB3DBB-BF3E-4F46-9559-CCC6A4F9DC19

RIDE 接口自动化请求体参数中文时报错:“UnicodeDecodeError: 'ascii' codec can't decode byte 0xd7 in position 9......”

在进行robotframework  接口自动化,在请求体参数中输入中文会报以下错误: UnicodeDecodeError: 'ascii' codec can't decode byte 0xd7 in position 9: ordinal not in range(128)..... 改mimetypes.py文件,路径位于python的安装路径下的Lib\mimetypes.py文件.在import下添加如下几行:解放参考如下: if sys.getdefaultencoding()