Skip to main content
All CollectionsIntegrations & APIs
Using the Webhooks and API to create your own business logic using Microsoft Power Automate
Using the Webhooks and API to create your own business logic using Microsoft Power Automate

Get creative with these solutions to help you do exactly what you need.

Updated over 2 years ago

Two warnings first:

  • This article is aimed at developers; it is technical and demonstrates tools and techniques that are not commonly seen by business users.

  • CargoSnap uses tools such as Excel, Power Query and Power Automate in these examples. These are Microsoft solutions and not part of the product offering of CargoSnap. We do not provide, sell or support these tools! We just think they are awesome to achieve business goals, but you may choose a competing product or use the described functionality in your own WMS/TMS.

TIP! Keep the CargoSnap API documentation handy.

Getting your data into Excel, from the API

Want to get your CargoSnap data into Excel (or PowerBI and similar)? Check out this video explainer:

Using Webhooks and API calls for your specific use case

"If this happens, then that should happen". There are so many scenario's imaginable. With Webhooks and API's you can now make it happen! Follow this showcase where we show a use case being solved with Microsoft Power Automate:

Please note that this video flow depicts a 'happy flow'; one where conditions are met and all data is well formed. For production level code, you probably will want to include some more sanity checks.

Annex: Pagination

In order to handle Pagination in Power Query, the following snippets will help:

For the endpoint /forms:

let
Source = List.Skip(List.Generate( () => [Counter = 0, isMore = true], each [isMore] <> false,
each [WebCall = Json.Document(Web.Contents( "https://api.cargosnap.com/api/v2/forms/[my-form-id]?"
& "token=[my-API-token]"
& "&limit=250"
& "&startdate=2020-01-01"
& "&enddate=2020-12-31"
& "&page=" & Number.ToText(Counter))),
isMore = if [Counter] < 1 then null else
if [WebCall][current_page] = [WebCall][last_page] then false else true,
Counter = [Counter] + 1
]
), 1),
#"Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
Source

For the endpoint /files:

let 
Source = List.Skip(List.Generate( () => [Counter = 0, isMore = true],

each [isMore] <> false,
each [WebCall = Json.Document(Web.Contents( "https://api.cargosnap.com/api/v2/files?"
& "token=[my-API-token]"
& "&limit=250"
& "&startdate=2020-01-01"
& "&enddate=2020-12-31"
& "&page=" & Number.ToText(Counter))),
isMore = if [Counter] < 1 then null else
if [WebCall][current_page] = [WebCall][last_page] then false else true,
Counter = [Counter] + 1
]
), 1),
#"Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
Source

Did this answer your question?