Creating or Testing HTTP Requests With an 'Echo' Channel

Creating or Testing HTTP Requests With an 'Echo' Channel

This strategy is helpful for constructing outgoing HTTP requests in Iguana, particularly when you are able to create working HTTP requests using a third party client such as Postman, but the same request does not work in the Translator. This is caused by differences in the formatting/structure of HTTP requests when constructing with different tools, so some work is required to match the HTTP request coming from Iguana with the HTTP request coming from Postman.

One method that we find useful for crafting HTTP requests in Iguana is creating a From HTTP ‘Echo’ channel, since this will allow you to see the actual HTTP request being sent out by net.http.post. This works by setting up a From HTTPS channel as follows

In the script for this channel, all that is required is

This sets up the channel so that any HTTP request sent to http://localhost:6544/echo (you will need to replace localhost with your IP address to reach this endpoint from a remote server) will receive as a response an echo of the request that was made. This can now be used to see what is being sent from other HTTP requests by switching the intended URL with the URL of the echo channel.

The below screenshots contain an example of how an http request can be updated and changed, while what is being sent in the request is updated live and observed by using trace(response) where response was the variable the http request response will be stored in. In this example I do not initially include any headers, and the echo response contains a few default headers but nothing else. After adding more headers to the net.http.post function they are included in the HTTP request that is sent out, seen in the echo response. In this manner an HTTP request can be built iteratively, confirming that it is formatted correctly at each step. The final step would be to update the URL to the desired web service endpoint.

 

 

We suggest setting up an echo channel and then directing the net.http.post request from Iguana to the echo endpoint, tracing the response as shown in the screenshots above to see what the request looks like when it is sent.

As well, direct your working Postman to the same endpoint. Then, you can analyze this HTTP request by opening the From HTTP Translator and clicking on the ‘None’ button next to Sample Data on the top left, then clicking the ‘Add from HTTP Request Log’ button (shown in screenshot below). This will show you the five most recent HTTP requests sent to the endpoint. Locate the Postman request (sending again from Postman if needed) and click to view it.

analyze http message

You should now have inside Iguana both the working HTTP request from Postman and the not working request from Iguana. Compare the two and tinker with the Iguana net.http.post function until they match, and your HTTP request from Iguana should work properly when directed back to the original endpoint.