Forum Discussion
Connect to API. Bearer Token
Hi
I am having a hard time connecting to data via API. I am attempting pull out data from Samsara, https://www.samsara.com/api#. (the website is public info). They use something called Bearer Token. I have my token. I have no issues making a call, and getting data via Terminal.
Could someone please tell me the steps in connecting to an API in PowerBI, having to use the company issued Bearer Token they provide to you.
The steps in PowerBI I took are....Get Data>Web. Have been unsuccessful. Please see pictures of the different things I have tried.
Thank you
25 Replies
- Mdauria6087New Member
Give this a shot.
- jusToddAdvocate IV
The solution that continues to be missed, offered up by jayhawk and again by Mdauria6087
Replace "3U2" with your token and you are on your way!
- AnonymousNot applicable
I am also struggling to connect to the same API using Power BI
I’ve followed the Samsara API Call documentation from here: https://developers.samsara.com/docs and attempted the following ‘First API Call’ Curl instructions but using Microsoft Power BI Desktop.
curl --request GET \
--url https://api.samsara.com/fleet/drivers \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access_token}'
The next menu asks for the Key and here I have used the API token again.
I get the message 'An API key value wasn't specified'
Please can anyone help me with this? Samsara have been unable to assist with the Power BI side of things.
- jayhawkAdvocate I
Anonymous Here ya go. You should be good to go bud.
Right click on the work List.
Right click on the work List again.
- AnonymousNot applicable
Hi,
Your solution worked for me too (put "Authorization" as header parameter and then "Bearer [Bearer_key]" as value.
But how can i setup a daily update when i publish my report ? Where do i put the bearer token ?
- tariqpervezRegular Visitor
I have a similar situation where I am trying to extract distance data of fleets through Fleet company's web API service. I am done with API authentication from where I got a ClientID, UserID & Token. Now using this information, I am trying to make API calls from power bi. Below are the snapshots of steps which I followed;
when the API call completes it shows null in data and an error
I have further expanded the error below. It says that "TotalDistance" property in "Distance" report cannot be set to a System.Decimal value it should be set to a non-null value of type System.Double
apart from this, I have tried making calls from their web API service portal and it runs fines and gives responses in JSON. Below is the snapshot of that
Please provide your valuable feedback on this problem.
- Mdauria6087New Member
Does anyone know how to get a full YTD dataset from the Samsara API. The endCursor is limiting me to 3 rows only.
Here is my call:
GET /fleet/hos/daily-logs?startDate=2022-01-01&endDate=2022-11-01&driverActivationStatus=active&expand=vehicle HTTP/1.1
Accept: application/json
Authorization: Bearer samsara_api_?????????????????????????
Host: api.samsara.com - KHC0587Frequent Visitor
Did anyone figure out how to set up automatic refreshes on this data source? I have been able to pull the data from Samsara (thank you all for the above support), but when I publish online, I can't set up refreshes due to missing web credentials?
This is my M-Script call:
Json.Document(Web.Contents("https://api.samsara.com/fleet/vehicles", [Headers=[Authorization="Bearer myapiKey"]]))
and off of the vehicle id columns i call:
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each Json.Document(Web.Contents("https://api.samsara.com/",[RelativePath = "v1/fleet/trips" & "?startMs=" & Text.From(Duration.TotalSeconds(startMs - #datetime(1970, 1, 1, 0, 0, 0))) & "000" & "&endMs=" & Text.From(Duration.TotalSeconds(Date.From(DateTimeZone.LocalNow())-#date(1970, 1, 1))) & "000" & "&vehicleId=" & [data.id], Headers = [Authorization = "Bearer " & "myapiKey"]]))),
- AnonymousNot applicable
Did you resolve this? I'm stuck with the same issue
- KHC0587Frequent Visitor
Unfortunately, no I never solved it, ended up just abandoning the project as leadership lost interest in it.
- PierlootRensNew Member
This solved it for me
- Mdauria6087New Member
You will need an API key for Samsara to use the BI web API access.
- SiddharthJainNew Member
- hi, have created a api token from samasara and provided all read acces with anyone in organization. I am giving they key but getting beloow
- jusToddAdvocate IV
Double check ... have you tried replacing <API Token> with the actual token?
should look like
Bearer samsara_api_VariousNumbersLetters
- hi, have created a api token from samasara and provided all read acces with anyone in organization. I am giving they key but getting beloow
- jusToddAdvocate IV
FYI: Apparently, Samsara is working on a PowerBI Connector to be released sometime towards the end of 2023.