AFNetworking says "cannot parse response" - ios8
I am sending a request to server, which is handling the request and responsding. However on my app I am receiving:
Error Domain=NSURLErrorDomain Code=-1017 "cannot parse response" UserInfo=0x167668d0
{NSErrorFailingURLStringKey=https://***, _kCFStreamErrorCodeKey=-1,
NSErrorFailingURLKey=https://***/, NSLocalizedDescription=cannot
parse response, _kCFStreamErrorDomainKey=4, NSUnderlyingError=0x16731990 "cannot parse
response"
Accept field in http request is adequate.
I cannot even see what messege is arriving, because NSHTTPURLResponse object is null.
What can be an issue and in what way I can see what message is coming not using things like wireshark.
Thank You!
I got the same problem, and the reason is that the API require GET http method, and I need pass a parameter, I send it by the following code:
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
When I execute the request with GET method, it will report the error.
My solution is when the API need GET method, the parameter should add on the URL, such as http://apiserver/api?paramName=paramValue, when the API method is POST, then use the code above, set the HTTPBody for the request object.
If iOS cannot parse response, the problem must be in improper format http response from server, even if You are said, that everything is 100% correct, bacause other services communicate with it.
In my case an Android app communicated successfully, because network framework used there was not so restrictive and even if the content-length of http response does not fit the actual length of data, it could read this message, unlike ios.
Use tcpdump to check http communication!
I got the same issue when I tried to call a web method using http GET method instead of http POST. The web service method was expecting POST request not GET. Hope this information will help some one.
If you are using (iOS8 has a problem with this but works in iOS7)
NSData *dataToSend = [jsonData dataUsingEncoding:NSUTF16BigEndianStringEncoding]
to send to the server, please make it as per below:
NSData *dataToSend = [jsonData dataUsingEncoding:NSUTF8StringEncoding]
I was seeing this error because a framework I was using was trying to send URL parameters in a GET request inside a JSON encoded body (instead of as URL-encoded parameters in the URL string as it should have been). That was causing the server send back an "invalid parameters message" which the client couldn't handle and instead aborted mid-request. Switching from body parameters to URL-encoded parameters for GET requests fixed the problem.
First I would ensure you are sending the correct parameters both in the body and the headers. I was receiving this error and after moving one of the parameters from the body into the header I received the correct response.
If there is any documentation for the api make sure you follow it properly.
Related
{"result":560,"type":"exception"} response for axs request in jmeter
I encounter {"result":560,"type":"exception"} response for axs request in jmeter while designing a script to do a load test for a mendix web application. First I encountered untheorized response on login so i used reg. expression extractor to extract CSRF-TOKEN and then login worked fine. after login and try to submit an application, i got {"result":560,"type":"exception"} response. what might be the issue and how can it be solved? Response body Response header Request body Request header
The issue is that you're sending an incorrect request. Unfortunately we cannot state what exactly is wrong because we need to see both: Reference successful request including URL, headers and body from i.e. real browser The request from JMeter which fails including URL, headers and body So I can only suggest to use a 3rd-party sniffer tool like Wireshark or Fiddler to capture the requests from the real browser and JMeter and compare them. Request must be exactly the same (apart from dynamic parameters which need to be correlated). Given you send the same request as browser does you should get the same (successful) response Other things to consider: Check your server log, it might be the case you will figure out the reason from there like it was in this forum thread Given you have Arabic characters in the request body ensure to use proper encoding, i.e. UTF-8 is always a good choice
When making request to GO Gin framework with bad uri, e.g. `/users/%` getting insta 400
I have encountered an interesting behavior of GO Gin framework. E.g. I have an endpoint GET which expects an ID, e.g. /users/1, while this works fine if you pass e.g. 1, during testing I have noticed that if you send /users/% it fails instantly and returns 400 Bad Request with content type text/plain; charset=utf-8. Now all is ok, but the tricky part is that I want to handle this error with custom error message and I want to receive content type as application/json; charset=utf-8. But the problem is that I can't figure out where this request is rejected as in logs I can't see that it was even called and the route looks not called at all. So my question is, how Gin handles bad uri query params like % and how it's possible to handle it in my own way?
Jmeter Response 500 internal server error for request
HI everyone I need a help regarding to fix the 500 internal server error Please check my below attached requests and correlation and response image Please tell me if I was wrong in anywhere I keep trying to do the scripts to run and the result was 500 error. Redirect request: Https request1: Data correlation: Passing parameters: Sending request details: Response message:
Looking into Content-Type header of your request it appears that you should be sending a JSON while you're sending parameters in form of name-value pairs I think you should switch to Body Data tab in the HTTP Request sampler and put your parameters there like: Also double check your API contract, it might be the case you need to change the method to POST More information: REST API Testing - How to Do it Right
no SOAPAction header! in Oracle service bus
I am facing below error in respose, <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode> <faultstring>no SOAPAction header!</faultstring> i am trying to fixing in pipeline , selected pass all headers through pipeline but didn’t helpedenter image description here
Do you really need a SoapAction? One of the options available in a proxy is to decide which operation a SOAP message is, by inspecting the message body. If someone sends a message (perhaps through a biz ref) and doesn't include a SOAP action header, a proxy will still recover if it uses this method.
POST call in Mulesoft
I am trying to make a HTTPS POST call in mulesoft to an external API. I had read in the mulesoft documentation and also in other posts that in order to send the request body, a map has to be prepared. Hence, i am using the "Set-Payload" to prepare a map. Eg: #[{'key':'value'}] When I am using the logger to display it, it prints a map (as expected). But when the POST call is being made, i am receiving the following error: Response code 503 mapped as failure. Message payload is of type: BufferInputStream Payload : org.glassfish.grizzly.utils.BufferInputStream#3f8f77a Could anyone let me know where am i going wrong? Thanks in Advance.
The server you're trying to call is returning status 503. Have you tried calling the external API using other client SOAP/Postman/Curl? Also check this out: http://forums.mulesoft.com/questions/2009/consume-get-restful-service.html
You should set proper mimetype for muleMessage and set the http POST method, then it should work.
While posting the data male sure how your http is expecting the input. What ever the transformations you want to make before posting do it, finally when posting the data to http cross check your data type with the data in the server your are trying to send. Both needs to match. Then it work.
I generally try to Isolate HTTP interaction problems into two parts. One is related to request itself for e.g. URL,Method,Headers,Payload,MimeType and other should be related to transport and network interaction with Server itself. To better view the information for both of the above details use a htt[ proxy/debugger [for. e.g. Fiddler] around the traffic flowing while you make a request. This will throw more light on the stuff hindering you while making this call successfully.
You can try any of the below sugestions-: Set payload as map, mention MIME Type as application/json and then use json to object transformer (with return class as java.util.HashMap). Set payload as simple string. This could help.
Status code 503 implies that the server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. Please try resending the message or hit the API with Postman.
It looks like you need to change the port in the request-config to 443 since you're using HTTPS. <http:request-config name="HTTP_Request_Configuration" protocol="HTTPS" host="jiratst.murex.com" port="443" doc:name="HTTP Request Configuration" basePath="/rest/api/2/project">
try using input {'key':'value'} in set payload instead of Array.