Getting null response from REST message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 01:01 PM
Hi All,
I configured two REST messages with two different end points and I am calling them from FIX script to see how they are working. I am passing one of the variables from the REST Message1 response as query parameter to the second REST message. So for instance if we get response for element1 for 15 times, we need to get the individual response for all those 15 from second REST message. See the sample response from REST message1 below.
"RESPONSE":{"DATE":"2018-12-06T12:18:17Z","TESTS":{"OUTPUT":[{"element0":"2018-12-12T16:50:42Z","element1":"1234","element2":"2018-12-05T16:00:40Z","element3":"CSV","element4":"989.51 KB","element5":{"element6":"Completed"},"element7":"XYZ","element8":"AAA","element9":"XXX"},{"element0":"2018-12-12T16:50:10Z","element1":"1321","element2":"2018-12-05T16:00:35Z","element3":"CSV","element4":"5.33 MB","element5":{"element6":"Completed"},"element7":"WYX","element8":"AAA","element9":"YYY"},
Here the issue is that i am getting response as null for some of the element1's. See my code below. I also tried adding HttpTimeout and waitForResponse but there is no change in the response body when I tested that. I also tried testing with the same element1 in postman tool, there i am getting the response but its taking 2 to 3 mins to get the response.
r.setQueryParameter("element1", newList[j]);
r.setHttpTimeout(200000);
var response = r.executeAsync();
response.waitForResponse(180);
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.print("response body is" +responseBody);
}
catch(ex) {
var message = ex.getMessage();
}
Can anyone please help me with this.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 01:23 PM
[your question]Here the issue is that i am getting response as null for some of the element1's
[My question]: Why do you think you are getting Null responses ? [asking you because it might help us get a solution]
If you are getting a response that contains NULL values in the response body, then its not the issue of the timeout. If the timeout occurs, it will give you an error instead of a response body.
Please let me know, why are you trying to wait for the response ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 01:28 PM
Hi Aman,
As per my understanding, I am getting null response because of the delayed response from server. I noticed late response(Aprox 3 to 4 mins) for the same elements in postman.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 01:52 PM
neha,
In Webservices, by nature,
1. Service Consumer [PostMan or your Rest Calls from Fix script] sends the request
2. Service Provider[3rd party app] receives your request
2.1 If the Service Provider is taking time more that what the request life time is, then it will respond back with a time out error [usually a status code of 408/504/599]
2.2 continuing the point 2.1: If the request times out, then you will not get a Response at all. you cannot get a partial response that contains some Null values [like you are describing], you get nothing but the error message.
3. If the Service Provider does the job without any timeouts, then it will respond back with the JSON response body[in your case]
So the bottom line is
- There is no chance for getting a partial Response Body, its either FULL or NULL.
Thank you,
Aman Gurram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 01:56 PM
So having that said, Please investigate with your 3rd party application to which you are sending the request to, they might be able to explain why you are getting NULL values in the response.