Skip to main content

Using PowerBI to connect to ValveTrack APIs

Guide on how to use the APIs with PowerBI desktop and powerbi.com

Updated over 3 months ago

API documentation

Swagger

All APIs are listed in swagger: Swagger UI.

APIs to be used by Power BI

The read only APIs to be used with Power BI are typically listed in Fields:

FieldId

You find the fieldId in 4Insight. It is available in the URL where your ValveTrack instance is published:

How to test the APIs in swagger?

Access

You will need access to 4Insight and the field to test - contact support for this access.

Authentication

You need to retrieve a bearer token:

Then:

Then past the token and click:

Try the API

Enter the fieldId and execute:

Connecting with PowerBI desktop

Access

A service account must be set up for you to get access. This must be set up by support:

Service account

Based on the service account you will get a client id and a secret - you need them both.

Parameters in PowerBI desktop

You need to enter the following parameters:

GetToken function

The GetToken function in the desktop file should look something like this:

= () => 
let
Data = Json.Document(Web.Contents("https://4subseaid.b2clogin.com/4subseaid.onmicrosoft.com/oauth2/v2.0/token?p=B2C_1A_SIGNUPORSIGNINWITH4SS_PROD&grant_type=client_credentials&client_id="& client_id & "&client_secret=" & client_secret & "&scope=https://4subseaid.onmicrosoft.com/4insight-api-prod/.default", [Headers=[#"Content-Type"="application/x-www-form-urlencoded"],Content=Text.ToBinary("")])),
access_token = "Bearer " & Data[access_token]
in
access_token

Calling the valves API

Here is an example how to call the valves API:

= Json.Document(Web.Contents("https://valvetrack-surf-api.4subsea.net/api/v1/fields/" & field_id & "/valves", [Headers=[Authorization=GetToken()]]))

Schedule refresh in PowerBI.com

You can the upload the desktop field and configure scheduled refresh.

Data source credetials

When setting this up you can skip test connection:

Did this answer your question?