Search code examples
apiproxypostmannewman

Setting local proxy within an API request


I'm having a problem within newman where I send a call out to worldpay to retrieve a token and I keep getting a 'getaddrinfo ENOTFOUND' error. Upon further investigation it was a proxy issue causing this - I then set newman to use the proxy but this then caused other issues where other requests would fail.

If I was able to set the proxy half way through the collection running - this would then work as the ones that fail when I set the proxy are before the worldpay call. Is it possible to set a proxy through an API request? If so how would I go about doing this?

Thanks in advance.


Solution

  • The solution to this was to set the proxy using the following:

    set HTTPS_proxy=http://ProxyIP:ProxyPort
    set HTTP_proxy=http://ProxyIP:ProxyPort
    set no_proxy= ##Url of blocked request(s)##
    

    Any further issues with requests getting blocked, simply add the URL of that request to the no_proxy using a coma (,) to separate each entry.

    If you want this to work within a release pipeline you'll have to add the above to your .npmrc file that your agent uses. This can be found within the user folder of that person.