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

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

解决办法:

NSString *pathStr=@"http://api.XXX.com/provider" ;
    
    NSDictionary *jsonObject = @{@"key":@"d85c713ef6704d651c7ce",@"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);
    }];

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

  1. nvm use (node版本号)时报错: exit status 1: ��û���㹻��Ȩ��ִ�д˲�����

    nvm use (node版本号)(例:nvm use 14.18.2)时报错: exit status 1: ��û���㹻��Ȩ��ִ�д˲����� 解决方法: 权限不够,以管理员身份运行cmd ...

  2. API集成测试问题2:Expected status code 200 but received 500. Failed asserting that false is true.

    接上文,之前的错误消失了,出现了新的问题如下: PHPUnit 8.5.0 by Sebastian Bergmann and contributors. .F 2 / 2 (100%) Time: ...

  3. 解决HuggingFace加载预训练模型时报错TypeError: expected str, bytes or os.PathLike object, not NoneType

    完整报错: TypeError: expected str, bytes or os.PathLike object, not NoneType 解决方法 检查下载的组件: 步骤1:完整的下载组件,包 ...

  4. python3.x执行post请求时报错“POST data should be bytes or an iterable of bytes...”的解决方法...

    使用python3.5.1执行post请求时,一直报错"POST data should be bytes or an iterable of bytes. It cannot be of ...

  5. 前端发起接口请求时报错:405 Method Not Allowed

    当我们发起请求后,发现报错405,用调试工具查看根本没有发出请求,405就是接口不存在. 这里首先排除下是不是接口名写错了, 其次询问后端这个接口有没有同步 再然后可能是HTTP调用方法错误,比如:定 ...

  6. httpclient对象请求时报错javax.net.ssl.SSLException: hostname in certificate didn‘t match

    学习httpclient对象请求时出现如下报错: 出现javax.net.ssl.sslexception报错是因为证书不匹配的主机名的问题. 可以在请求的时候多加上表示修改org.apache.ht ...

  7. 运行时报错RuntimeError: expected device cpu but got device cuda:0

    最近在运行pytorch代码时发现的该错误,不管是 expected cpu 还是 expected cuda, 本质原因都是类型不匹配. 一般是因为: 等号左边和右边类型不一样 运算符左右两端类型不 ...

  8. 打包vue项目时报错:Expected indentation of 6 spaces but found 10

    Expected indentation of 6 spaces but found 10根据字面意思应该是代码格式不符合要求,根据idea的reformat code自动格式化代码,结果这个错误越报 ...

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

    在进行网络请求时出现-1016 是因为只支持 text/json,application/json,text/javascript 你可以添加text/html 一劳永逸的方法是 在 AFURLRes ...

最新文章

  1. 深入理解分布式技术 - 两阶段的应用 MySQL XA 规范
  2. 批处理for命令详解(转) 批处理for命令详解
  3. 计算机刷帖知识点,09计算机408分(沙滩帖)
  4. leetcode内存消耗
  5. 前端学习(736):函数的返回值return
  6. Using the isBranch() method to determine if a Tree item is a branch or leaf
  7. DLL调用异常:The value of ESP was not properly
  8. 【ASM】如何创建ASM磁盘
  9. 网络处理器(NP)与图形处理器(GPU)
  10. 《符号学:原理与推演》(一)符号的构成
  11. 职业学校计算机课评课,中职计算机评课稿
  12. ov7725图像帧率计算公式总结
  13. unity2018转微信小游戏不显示图片
  14. 5G网络用户面时延测量
  15. ubuntu下添加日语输入法
  16. ReferenceQueue、Reference详解
  17. Cutecom无法打开USB串口
  18. 云计算厂商们,你们辜负了中国的用户
  19. 虚拟光驱软件 daemon tools lite 4.4 下载 2011最新版
  20. asp.net921旅游博客网站系统

热门文章

  1. 零跑C11“领跑中国”,全球第二家自研并量产辅助驾驶芯片的车企
  2. 构建复杂应用的神器,FBroadcast
  3. ESP32 Arduino (六)TFT屏幕连接无线局域网投屏
  4. 免费http代理可用率高吗?
  5. 开发高可移植性J2ME的软件测试篇
  6. 日本語トレーニング18
  7. Windows环境下个别Gem包安装不上的解决办法
  8. 考勤管理系统的设计与实现
  9. 【哈希-简单】953. 验证外星语词典
  10. 奔腾G7505怎么样 相当于什么水平