Table Of Contents

Retrieving Data From a Web Service

Last Modified: November 16, 2020

Before you begin, open or create a web application project.

What to Use

What to Do

Create the following diagram to retrieve data from a web service and display that data on the panel.

Customize the gray sections for your unique programming goals.

Communicating With a Web Service Diagram
If you want your web application to run continuously in a web browser, place your code in a While Loop with a False constant wired to the condition terminal. Otherwise, your web application runs only once in the web browser.

You can run your web application again by refreshing the page.

Place the code that calls the web service within a Case Structure. The Case Structure prevents the GET node from making a request to the web service in each iteration of the While Loop. Making a GET request each time the While Loop iterates is unnecessary because the data you're accessing probably doesn't change as quickly as the loop iterates. Most web services also limit how many requests you can make per second and may even ban your IP address if you make too many requests.
Enter the URL of the web service that you want to call. You can replace this code with a string constant containing the URL of a web service. You can also create code that programmatically creates a URL based on user input. In this example, Minimum Magnitude and Number of Earthquakes to Display determine what values make up the URL.
The GET node sends a request to the web service and returns data from that web service. In this example, the GET node sends a request to the U.S. Geological Survey web service and returns the latest earthquake data.
Create a subWebVI that parses the data that the web service returns. The web service in this example returns data in the JSON format, which is what most web services return. Other common data formats are XML, CSV, and YML. If a web service returns data in a format other than JSON, you can use other String nodes to parse that data.
To reduce load and improve performance when you run your built web application on a web browser, add a Wait node to any WebVI that uses an infinite While Loop.


If the GET node doesn't return any data or returns unexpected data, verify the following conditions:

  • The URL is correct. Test this by navigating to the URL in a web browser.
  • The website or web server you want to access is running. Test this by navigating to the URL in a web browser.
  • You have a working internet connection.

If each of these conditions is true, try one of the following:

  • To check the status of an HTTP GET request, wire an indicator to the status code output of the GET node.
  • To check detailed information about the HTTP GET request, including its status, wire an indicator to the headers output of the GET node.

Refer to the W3C website for more information about HTTP status codes and headers.


Search within the programming environment to access the following installed examples:
  • Call a 3rd Party Web Service
  • Call LabVIEW Web Service

Recently Viewed Topics