Handling Large Responses In API
In today’s world there are many API testing clients like postman, restlet etc. in which we can manually verify the response as per its corresponding request. But as we all know each software has its own limitation, and in this article, I will let you know a few of them which I faced and the way to resolve that issue.
Let us take an example of an application having millions of users or having any records in millions and we want to export that through API then by obvious we use API testing apps like post man or restlet client. But in case of exporting millions of record through API, Postman “Crashes” and shows a blank screen and same is with the restlet client it shows the response to download in xml format but full response is not displayed in it.
So, the question arises how to test/ verify the response now??????
Is there any solution?
The correct answer is yes there is a solution and the solution is curl and as we know curl is a command line tool use to hit servers like http/https/pop3 etc. you can setup it through other means or if you can access to your app server through putty then you can directly check it from there and saving your xml/json request in any folder of application
For example in below shown command you can see that I have saved my request in temp folder of my app server and called API request using POST method :
Curl Command : curl -H “Content-Type: text/xml” -d @./temp/exportData1.xml http://qa-app42.adaptiveplanning.com:1712/api/v18
- The text highlighted in grey show the curl command having content type or we can say the request format in xml form
- The text highlighted in yellow shows the path of the .xml file in which the response is been kept.
- The text highlighted blue shows the url on which the API hit its request.
Also we can hit the direct API in through the command as shown in the below :
Curl Command : curl -H “Content-Type: text/xml” -d “<?xml version=\’1.0\’ encoding=\’UTF-8\’?><call method=”exportData” callerName=”a string that identifies your client application”><credentials login=”firstname.lastname@example.org” password=”aaa”/></call>” https://localhost:1029/api/v18.
So these two are the ways to run API through curl if your Postman / Restlet Client is unable to handle big responses.
Author : Mohsin Khan