From a Dataminer installed on an internal network at a customer we need to do an API call to a cloud application. There is no direct access from this server, so a proxy server has been set up in the middle to make the communication possible. This has been setup as a default proxy on the windows machine. When testing this API access via the browser or via postman from this machine, the API call works (by passing via the configured proxy), no need to configure anything on browser level or in Postman. However when doing the call from automation using HttpClient the proxy is not used. The only way to make it work it seems is to hardcoded the proxy in the automation script as follows:
Is there another way to make sure the httpClient use the system configured proxy without hardcoding this using a proxy in the script ?
The reason why this works out of the box in Postman and the browser is because those processes will be running as the user who has the proxy settings configured in Windows.
SLAutomation (and as a result all your automation scripts) run as the NT_AUTHORITY/SYSTEM user. One of the ways to avoid having to configure the proxy server details in your script would be to configure them on that user in Windows similar like how it was already configured on that other user.
How to set up a proxy for Local System account at the machine level describes how you can easily set this up.
After having configured those settings, HttpClient will use those by default, so you can just do the following:
var client = new HttpClient();
var response = client.GetAsync("https://community.dataminer.services");
And the request will be sent through the proxy.
Hello David,
I think to build an interactive automation script could be usefull in this case. You could ask for the proxy address the very first time the automation is executed, save that value and then include a flag or something to the automation knows that the proxy parameter is already set and it just has to stablish the connection.
If you want to go deeper into this, you can check the Help in your DataMiner Cube App and then go to Advanced DataMiner Modules > DMS Automation > Using CSharp code in Automation scripts > Building interactive Automation scripts with CSharp.
I really have not had the oportunity to implement one of these interactive automations but I hope this could be usefull helping you to solve you problem.