Home
Quickstart Guide
Introduction RIO Academic RIO Application examples Your first RT app Your first FPGA app
Real-Time
Basic procedures System admin File system I/O monitor System controller architecture Timed loops Inter-process communication RT/Host communication RT/FPGA communication FPGA personalities Interrupts Datalogger (file I/O)
FPGA
Design flow Simulation Inter-process communication RT/host communication Derived clock domain IP blocks FPGA personality
Networking
Get connected Email Web services UDP TCP IP addresses
Site Map
Guides Code examples Procedures Tags LabVIEW block diagram elements Targets Communications All pages
Glossary How to use About
RIO Developer Essentials Guide for Academia
RT code example

Call a Web service

Form a query string as a URL, retrieve the JSON string served by the Web service, and parse the JSON string to extract useful information.

LabVIEW RT block diagram snippet: Call an API and parse the returned JSON string

Use cases

Features

Keep in mind

LabVIEW block diagram elements

Locate these elements with "Quick Drop" (press Ctrl+Space and start typing the name); click on an icon to see more sample code that uses that element:

HTTP Get
Format Into String
Unflatten From JSON

Example code

Troubleshooting tips

  1. “Error 7 occurred at Call Library Function Node in LabVIEWHTTPClient.lvlib:GET.vi” (File not found.) – This error indicates that the Academic RIO Device is missing the required software set add-on called “HTTP Client with SSL Support.” See manage the Academic RIO Device software set add-ons to learn how to install this required software add-on.
  2. “Error 59 occurred at LabVIEWHTTPClient.lvlib:GET.vi” (The network is down, unreachable, or has been reset) – Check the Device Network Configuration page (browse to 172.22.11.2) to determine if one of the active network adapters has a “Gateway” IP addresses that is something other than 0.0.0.0. Also try running the “check internet access” VI located in under “My Computer” to learn whether or not your development system can reach the Internet.
  3. “Error 363507 occurred at LabVIEWWeb serviceClient.lvlib:Send.vi” (LabVIEW could not verify the authenticity of the server) – verify that the Device system date and time are both correct so that the secured-HTTP connection (HTTPS) works properly. The Academic RIO Device does not have an onboard real-time clock (RTC), therefore each power cycle resets the date back to potentially many months into the past. Learn how to set the RT system time and date either with NI MAX or with your browser.

Suggested modifications

Evaluate your ability to call a Web service from a LabVIEW application by modifying one of the existing demo VIs to perform one or more of the following tasks:

  1. Request “fake data” from the “JSONPlaceholder” Web service (https://jsonplaceholder.typicode.com. For example, https://jsonplaceholder.typicode.com/users returns an array of user records (name, address, email, phone numbers, etc.), https://jsonplaceholder.typicode.com/users/2 returns the second record, and https://jsonplaceholder.typicode.com/users?username=Delphine returns the record for user “Delphine”.
  2. Generate a truly random number from the “Quantum Random Numbers Server” maintained by the Centre for Quantum Computation and Communication Technology at Australian National University https://qrng.anu.edu.au. For example, https://qrng.anu.edu.au/API/jsonI.php?length=5&type=uint16 returns five decimal random numbers between 0 and 65535. See the JSON API documentation at https://qrng.anu.edu.au/API/api-demo.php for complete details.
  3. Retrieve the current weather data from the “OpenWeatherMap” API http://openweathermap.org/api. Click the “API doc” link to learn the specifications of query strings and the returned JSON strings.
  4. Find and use another JSON-based web service of interest to you.

Expected results

https://youtu.be/a43AQp3M3DU (2:21)

Developer walk-through

https://youtu.be/xpVLENDliPI (5:07)

For more information