REST API calls exercise

Estimated duration: 2 hours

Introduction

It is possible to send calls to external endpoints from within a Novulo application to request information or to send files or other data. Received data can be stored and processed further. This is useful when the Novulo application needs to be connected to an existing software infrastructure or external services.

A few test endpoints have been built. You can play around with different parameters on this website

What you are about to learn

  • How to execute GET and POST calls from within a Novulo application
  • How to import/process received data

Prerequisites


1. Solar flares

You are a developer at a space agency. It is your responsibility to facilitate communication between the base station on earth and the astronauts that orbit earth on the ISS. It is important for the astronauts to be up-to-date regarding critical information like solar flares and tasks. The base station on earth provides multiple endpoints where astronauts can request important data. Your goal is to configure the Novulo application for the astronauts to ensure that they stay up to date.

A) A solar flare endpoint is provided to retrieve the intensity and the probability of solar flares on the ISS based on the date time and the coordinates of the ISS relative to the earth.
Use the following endpoint to get the solar flare probability by using call templates

If you get stuck, read the following posts:

B) The GET call for the solar flares uses URL parameters. The URL parameters change with every call. Therefore, it is not feasible to set up a call template for every call or to change the URL at the call template every time. Modify the call template so that you can use URL parameters to send calls with a dynamic URL.

Use this post if you get stuck: How to set dynamic URL parameters in a call template?

Solutions

A)

B)

Remove the url parameters from the call template. Then execute a call with the following parameters: [<“latitude”,52.21833>,<“longitude”,6.89583>,<“datetime”,“2024-12-08 12:00:00”>]


2. Downloading Tasks

A) The space agency provides a list of tasks for each astronaut. Retrieve the list of tasks and import them into the application as N_Activity records of the type ‘Task’. The exercise is complete when all tasks have been imported to the Novulo application and can be viewed and edited under All views > Activities.

Hint: Make sure that you know how imports work for XML files. Follow the import exercise first or read the articles below.

Use these posts if you get stuck:

Bonus: If the import succeeds for the XML response, you can try and import the JSON response of the JSON endpoint. The tasks in the response are the same.

Hint: The Novulo import engine cannot process JSON directly, which is why any JSON is automatically converted into XML before it is being fed into the sequential import. However, the auto-converted XML will contain multiple tags that have to be accounted for in your import definition. Duplicate the import definition that you already have and modify it to support the converted XML.

Solutions

A)






3. Updating task status

The space agency expects you to report the new status for tasks when they change. Send a call to the endpoint to update a single task.

If you get stuck, read the following post:

A) Use the following endpoint to send the status update for a single task with guid “7e8a9c0c-11f1-4b67-aa9a-dff82228e3d7”. The new status must be “Started”.

The JSON body of the call should look like this:

{ 
"guid" : "7e8a9c0c-11f1-4b67-aa9a-dff82228e3d7", 
"status" : "Started" 
}

Hint: To escape “ signs in Novulo expressions use \”.

B) Updating each task one by one is not feasible. Therefore, a new approach is required to send a status update for all tasks at once. Another endpoint exists to update multiple tasks at once. Send a call to the endpoint to update multiple tasks at once.

The JSON body of the call should look like this:

{ "tasks" : [
    { 
    "guid" : "7e8a9c0c-11f1-4b67-aa9a-dff82228e3d7", 
    "status" : "Started" 
    },
    { 
    "guid" : "987e6543-e21b-12d3-a456-426614174001", 
    "status" : "Not started" 
    }
]
}

Endpoint: https://joachimtools-eqcna3f6a4bndbak.westeurope-01.azurewebsites.net/spaceagency/update_tasks.php

  • Method: POST
  • Content-Type: JSON
  • Authentication: Bearer token 14a0b3359bd211444f3738754a579ae0”

Solutions

A)

Make sure to link a call account to the call template that has a bearer token set.

B)

Call template:

Data definition 1 of 2:

Data definition 2 of 2:

Fields in data definition 2: