Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
GillesWA
New Member

Get data from web api

Hello, 

i try to load data from an API WEB but i have an error : 

 

DataSource.Error: Web.Contents failed to get contents from 'https://app1pub.smappee.net/dev/v1/oauth2/token' (400): Bad Request
Details:
DataSourceKind=Web
DataSourcePath=https://app1pub.smappee.net/dev/v1/oauth2/token
Url=https://app1pub.smappee.net/dev/v1/oauth2/token

 

Here is my code : 

let
// Concatenates the Consumer Key & Consumer Secret and converts to base64
authKey = "Basic " & Binary.ToText(Text.ToBinary("MyID:MySecret"),0),
url = "https://app1pub.smappee.net/dev/v1/oauth2/token",
// Uses the smappee POST oauth2/token method to obtain a bearer token
GetJson = Web.Contents(url,
[
Headers = [ #"Authorization"=authKey,
#"Content-Type"="application/x-www-form-urlencoded;charset=UTF-8"],
Content = Text.ToBinary("grant_type=password&
client_id=[MyID]&
client_secret=[MySecret]&
username=[MyUserName]&
password=[Mypwd]")
]
),
FormatAsJson = Json.Document(GetJson),
// Gets token from the Json response
AccessToken = FormatAsJson[access_token],
AccessTokenHeader = "bearer " & AccessToken,
// Uses the spappee GET search method using the bearer token from the previous POST oauth2/token method
GetJsonQuery = Web.Contents("https://app1pub.smappee.net/dev/v1/servicelocation",
[
Headers = [#"Authorization"=AccessTokenHeader]
]
),
FormatAsJsonQuery = Json.Document(GetJsonQuery)
in
#"FormatAsJsonQuery"

 

and here is the documentation of the API

 

Use your application's credentials and the user's credentials to retrieve an access token by sending a HTTP POST message to 

https://app1pub.smappee.net/dev/v1/oauth2/token

 

POST /dev/v1/oauth2/token HTTP/1.1
Host: app1pub.smappee.net
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
 
grant_type=password&
client_id=[YOUR_APP_ID]&
client_secret=[YOUR_CLIENT_SECRET]&
username=[USER_NAME]&
password=[USER_PASSWORD]
 
 
Somebody could be help me ??
 
thanks in advance
1 REPLY 1
Anonymous
Not applicable

@GillesWA,

You can use Fiddler to trace your HTTP traffic and see what the detailed message is. And I would recommend you contact smappee support about how to get access token using the API.

There is also a similar blog about how to use Power Query to get data from web API for your reference.
https://www.kasperonbi.com/getting-data-into-power-query-with-the-twitter-search-api-how-to-hack-pq-...

Regards,
Lydia

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.