This site uses cookies to bring you the best experience. Find out more
Skip to main content

blog

Accessing a RESTful Web API from LabVIEW

We had a requirement recently to save data from a cRIO to a SQL database on a server via a RESTful API. We were responsible for both the LabVIEW code on the cRIO and the development of a C# RESTful Web API.

LabVIEW communication with the Web API was enabled by two VI Package Manager (VIPM) toolkits: JKI Rest Client and i3 JSON. JKI Rest Client enables retrieving and sending of data using POST, PUT, GET and DELETE methods. Our case required using POST to send new data and GET to retrieve data based on optional parameters. Both methods assume data is presented in JSON (JavaScript Object Notation) format. LabVIEW has built-in functions to format clusters into JSON, but instead of using these we found the i3 JSON Toolkit to be more useful.

The i3 JSON toolkit utilises Variant Attributes (this approach was presented at a MLUG meeting in 2016) as a storage container and therefore allows you to add, delete, set and retrieve data in a really flexible manner. Once the JSON string is obtained from JKI GET function, it can be transformed into i3 JSON format and left in that form for further processing. Similarly, instead of formatting the JSON string ourselves, it is possible to use i3 JSON representation to add all the required data and then transform it into a JSON string to be sent to the Web API via JKI POST function.

Keep an eye out for a follow up post on what we did server side with the Web API. If you’d like to discuss your LabVIEW challenges, either come along to the user group we host or get in touch.

Back to Blog listings

ARGENTA IS A LEADING PROVIDER OF PRODUCT RELIABILITY AND PROCESS IMPROVEMENT SOLUTIONS.

Call 0121 514 2290 to discuss your requirements