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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

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
Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.