Webcockpit API to Excel via OData-Feed

Connect Webcockpit data to Excel using OData.

This is a guide on how to import data from a Webcockpit API to Excel using Power Query and the getsalesperbusinessday API as an example.

Step-by-Step

  • Open a new Excel Sheet
  • On the data tab click on ‘Get Data’ -> ‘From Other Sources’ -> ‘Blank Query’
Get Data from Blank Query
  1. In the Power Query Editor that is now open, click on ‘Advanced Editor’
Advanced Editor in Power Query
  1. Replace the content in this editor with the following code and click on ‘Done’
plaintext
let
url = "https://api.webcockpit.app/api/Default/getsalesperbusinessday",
headers = [
#"accept" = "application/json",
#"X-Api-Key" = "",
#"Content-Type" = "application/json"
],
postData = Json.FromValue([BusinessDay = "2023-12-14"]),
response = Web.Contents(url, [Headers=headers, Content=postData]),
jsonResponse = Json.Document(response)
in
jsonResponse
  1. When the data was successfully loaded you will see the following screen from where you need to transform the result into what works best for you.
Data loaded in Power Query

Further Steps

If you need data from a different API endpoint you just need to adapt the ‘url’ parameter and the value of the ‘postData’ object. 

Using the getsalesandguestsforbusinessday API as an example, the changes would look like this

plaintext
url = "https://api.webcockpit.app/api/Store/getsalesandguestsforbusinessday"

postData = Json.FromValue([CountryCode= "<Your CountryCode>", StoreNumber= <Your store number>,  BusinessDay= "2024-01-16"])