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 *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"];
    
    
    
//    NS

Calling AppiumDriver.replaceValue() with args: [["离线地图"],"ec66cc6b-04c5-4e2a-8b1d-2ae4c59d36ed","551733e3-e9a3-41e4-8c4e-f6790d7b1b2a"] [WD Proxy] Matched '/element/ec66cc6b-04c5-4e2a-8b1d-2ae4c59d36ed/value' to command name 'setValue' [Protocol Converter] Added 'value' property ["离","线","地","图"] to 'setValue' request body [WD Proxy] Proxying [POST /element/ec66cc6b-04c5-4e2a-8b1d-2ae4c59d36ed/value] to [POST http://127.0.0.1:8200/wd/hub/session/23edcf23-d356-4085-a574-ae688e54693f/element/ec66cc6b-04c5-4e2a-8b1d-2ae4c59d36ed/value] with body: {"elementId":"ec66cc6b-04c5-4e2a-8b1d-2ae4c59d36ed","text":"离线地图","replace":true,"unicodeKeyboard":true,"value":["离","线","地","图"]} [WD Proxy] Got response with status 400: {"sessionId":"23edcf23-d356-4085-a574-ae688e54693f","value":{"error":"invalid element state","message":"Cannot set the element to '离线地图'. Did you interact with the correct element?","stacktrace":"io.appium.uiautomator2.common.exceptions.InvalidElementStateException: Cannot set the element to '离线地图'. Did you interact with the correct element?\n\tat io.appium.uiautomator2.handler.SendKeysToElement.setText(SendKeysToElement.java:87)\n\tat io.appium.uiautomator2.handler.SendKeysToElement.safeHandle(SendKeysToElement.java:115)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:41)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:262)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:256)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:68)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.chann... [W3C] Matched W3C error code 'invalid element state' to InvalidElementStateError [W3C (551733e3)] Encountered internal error running command: io.appium.uiautomator2.common.exceptions.InvalidElementStateException: Cannot set the element to '离线地图'. Did you interact with the correct element? [W3C (551733e3)] at io.appium.uiautomator2.handler.SendKeysToElement.setText(SendKeysToElement.java:87) [W3C (551733e3)] at io.appium.uiautomator2.handler.SendKeysToElement.safeHandle(SendKeysToElement.java:115) [W3C (551733e3)] at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:41) [W3C (551733e3)] at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:262) [W3C (551733e3)] at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:256) [W3C (551733e3)] at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:68) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345) [W3C (551733e3)] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345) [W3C (551733e3)] at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435) [W3C (551733e3)] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) [W3C (551733e3)] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267) [W3C (551733e3)] at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345) [W3C (551733e3)] at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345) [W3C (551733e3)] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366) [W3C (551733e3)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352) [W3C (551733e3)] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911) [W3C (551733e3)] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) [W3C (551733e3)] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611) [W3C (551733e3)] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:552) [W3C (551733e3)] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:466) [W3C (551733e3)] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438) [W3C (551733e3)] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140) [W3C (551733e3)] at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144) [W3C (551733e3)] at java.lang.Thread.run(Thread.java:933)
最新发布
07-24
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值