Video guide · 3:11

Pull Data from a REST API into a Handheld App

Learn an endpoint from a curl command, try it, and call it from a workflow, so a scan fills the description and the quantity on hand from your API.

What you will learn

  • Start a web service connection from a curl command
  • Keep the token safely on the server and try the endpoint
  • Call an API from a workflow, with the scanned value in the path
  • Keep fields from the reply, and handle a failed call

Transcript

In this guide you will connect StepVane to an API endpoint, and use a workflow to pull data from it. A worker scans an item, and the description and the quantity on hand are filled in from your API.

We start with a new app that has one page with three fields: an Item to scan, a Description, and the quantity On hand. The goal is to scan an item, and fill the other two fields from your API.

Now the connection. Open Data, then Connections, and press Add connection. Choose Web service. The quickest way to set one up is to start from an example. Open Start from, choose curl command, and paste the curl command from your API documentation. Then press Read.

StepVane reads it for you. It finds the base address, guesses the sign in, a bearer token, and lists the endpoint, with the item number turned into a value you can fill in. The token it found is never shown. Choose Keep it, so it is stored encrypted on the server, and press Use this.

Before you use it, try it. Under Try it, pick the endpoint, type an item number, and press Send. StepVane shows exactly what was sent, with the token hidden, and what came back: here a two hundred, and the item as JSON. Press Use this reply as a sample, so the workflow can offer its fields.

Now the workflow. Open Workflows and press New workflow. Choose A field is entered, pick the Item field, and name it Item entered. It will run whenever an item is scanned.

Add a step, and choose Call an API. The connection is Item API. Pick the endpoint, and StepVane fills in the method and the path. Where the path has the item number, put the Item field: so the address changes with every scan.

Under Keep from the reply, press Keep a reply field. Studio shows the sample reply we saved. Click description in the reply, and choose the Description field as its target. Then press Also keep, and do the same for on hand.

If the API cannot find the item, or cannot be reached, the failed lane runs. Add a beep with the error tone, and a message, so the worker knows to scan again.

Now try it. Press Simulate, scan an item number, and watch the description and the quantity on hand arrive from the API. An unknown item takes the failed lane.

That is how you pull data from an API. Set up the connection once, call it from any workflow, and keep the fields you need from the reply. The same steps work for any API that returns JSON or XML.

Related

More guides

Start with one device today

Free for Studio, one handheld and one worker. No cloud account, no credit card.