I am trying to call a SAP API from Ignition. The API works correctly in Postman and browser, but when I call it from Ignition I am getting 403 Access Denied (SAP ICM error page).
The same request works in Postman with Basic Auth, but Ignition returns 403.
Thanks.
I believe Postman automatically base64 encodes your credentials. Try deleting lines 4 through 6 in your Ignition code and replace with this:
import base64
credentials = "your_username:your_password"
encoded = base64.b64encode(credentials.encode("utf-8")).decode("utf-8")
headers = {
"Authorization": "Basic " + encoded,
"Accept": "application/json"
}
If that doesn’t work, make sure the Ignition gateway’s IP is allowed in SAP’s icm/HTTP/auth or ICM allow rules.
Thank you @Bushmatic for your response. I tried the approach you suggested, but the issue still persists. I think I should now loop in the SAP team regarding the ICM related query. Furthermore, I have attached a snapshot after performing the Base64 encoding.
system.net.httpClient handles the basic auth header and encoding when you specify the username and password, you don't need to do it yourself.
Thanks for the clarification.
I understand that system.net.httpClient() handles the Basic Auth automatically. However, I have already tried passing the username/password directly as well as manually replicating the headers from Postman, but I am still getting HTTP 403.
Since the request works in Postman, could you please suggest what else might be missing in the Ignition request?
Share your postman config, or better compare a Wireshark capture between the two.
Thank you for the suggestion about comparing the requests using Wireshark. That hint helped a lot. After capturing and inspecting the traffic, I noticed that Ignition was sending the request with a different HTTP protocol behavior compared to Postman. I then explicitly set the HTTP version to HTTP_1.1 in the system function and after doing that the issue was resolved and the API started responding correctly.
Appreciate the guidance!
Script:
Wireshark Postman response:

Wireshark Ignition response:
