I'm trying to use system.net.httpClient
to post data to DataDog and have it working in my local laptop Designer in the script console (internet-connected) but it's not working in the Designer script console running directly on the GW, also internet-connected.
I can access the datadog POST url from a browser on the GW and it returns the same thing as in my local laptop browser.
This is the error I'm getting from the GW designer:
Cause: java.net.ConnectException
Message: Unable to POST https://api.datadoghq.com/api/v2/series
Traceback (most recent call last):
File "<input>", line 4, in <module>
File "<module:shared.gateway.diag>", line 298, in writeMetricsToDataDog
IOException: java.io.IOException: Unable to POST https://api.datadoghq.com/api/v2/series
This is the crux of the script:
api_url = 'https://api.datadoghq.com/api/v2/series'
headers = {'Accept': 'application/json', 'Content-Type': "application/json", 'DD-API-KEY': api_key}
data = {"series": datapoints}
data = system.util.jsonEncode(data)
...
LN 297: http = system.net.httpClient()
LN 298: response = http.post(url=api_url, data=data, headers=headers)
Edit:
The Ignition service is running under a domain service account. I'm checking if it has internet access.