I have been recently using Azure Blob Storage to store and access data in an Ignition project. I have had success using a GET request to access the stored data. The issue I am having however is using a PUT request to upload data from Ignition. I believe I am having difficulty in constructing the authorization header, but I am not completely sure. I am currently receiving a 403 HTTP response code (meaning Client authorization is not acceptable I believe). Has anyone been able to successfully accomplish something similar?
What Ignition version are you using? Can you share any of your script so far?
For a variety of reasons, I highly recommend system.net.httpClient() for interacting with REST/web APIs.
The system.net.httpClient() is definitely something I have been using. The PUT request has been providing a 403 HTTP error as well as a compiling error that states āContent-Lengthā is a restricted header (when included). The exact code I am using is included below:
I noticed that about a week ago a nightly fix was uploaded to the HTTP client POST function. The fix was aimed at resolving corruption when posting binary data. As seen in this post, I am using a PUT request and still seem to observe some data corruption on the byte arrays that I have been using (ie Content-Length is still incorrect). Has anybody been able to find a functional work-around or have any insight into how to resolve this problem? Also, is it possible that the bug identified in the POST function exists in the PUT function as well?
So I was actually able to get the API call to work. The C-based library compatibility presented itself as an issue when trying to use the Microsoft provided functions. The API call however uses generic libraries/functions, provided by ignition, for HTTP requests. A solution that worked for me was using the PUT BLOB call of the Azure Cloud Storage. The file intended for upload needed to be split up into smaller chunks and uploaded independently. After that I was able to upload and download to the Azure Cloud.
Worth mentioning for future readers that Postman is a phenomenal tool for testing APIs. See https://www.postman.com/. Using a tool like this will help you clarify whether the request itself is set up right.
I just wanted to thank you for posting this. It was very helpful in quick-starting Azure Blob Storage interaction. I had to remove āContent-Lengthā from headerVals, but otherwise it worked perfectly!
At our company we are moving our ERP-system from onprem to the Azure cloud. We are planning to connect with Busines Central (BC) through webservices (APIās). At the moment we use almost standard queryās for everything.
But I have only limited knowledge regarding connecting to the cloud. I have been told BC will use OAuth2.0 authentication. In Postman I was able to connect to the test cloud environment. But is there somewhere I can get information on how to perform this trick in Ignition?
I am unsure of the exact solution you would need, as I have never worked with BC before. I suspect that you could build out a template for API connections and use Ignitions scripting functions to establish that connection. The template would look something like the code posted above, but it would include only the information provided by the MS documentation. I have included one of the more general landing pages for such documentation that I briefly looked through.
Jonas, thank you for the quick response.
We do have an external partner for implementing the BC ERP-system. They have knowledge regarding the available APIās for BC.
Iāll try with modifying the code above you are referring to.
So the code pasted above is specifically for a Put Blob request into Azure. It may help guide you in replacing some of your standard queries you mentioned. In regards to establishing a simple connection, nearly all of the overall structure and library imports can be disregarded. Iām not all that familiar with 0Auth2.0 authentication, so it may be worth reading about its relationship to the services you need.
If I am correct 0Auth2 is implied from Q1 2022, so like āas we speakā. I donāt know much about it either. I was able to create an GET request to it in Postman. But now I need to translate this to Ignition.
I know it's been quite some time but... Thank You!! I was able to get this working in a fraction of the time it would take to sort it by myself from scratch.