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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
newuserpowerbi
Regular Visitor

Post Request Embed Token Individual Key

Hi guys,

 

I'm new to PowerBI and I have a question regarding Post request method,

we have a service API that we like to use PowerBI to connect to get data where clients and do reporting,

we tried to setup a connection between powerbi desktop and our API through Post request

 

 

What we have problem is  where do I put in the values for individual key and how do I also send in a request body that's recognized by PowerBI? 

Thanks

 

 

 

3 REPLIES 3
v-ljerr-msft
Employee
Employee

Hi @newuserpowerbi,

 

Based on my research, the PostContents is JSON format, try to specify 

Headers=[#"Content-Type"="application/json"]

What do you mean about the individual key, is it authentication key? If yes, the formula(M) below is for your reference. Smiley Happy

let
    AuthKey = "abc",
    url = "efg",
    Source = Json.Document(Web.Contents(url,[
             
         Headers = [#"Authorization"=AuthKey ,
                    #"Content-Type"="application/json"],
         Content = Text.ToBinary(body) 
             ]   
        ))
in
    Source

Regards

Hi guys,

 

I'm new to PowerBI and I have a question regarding Post request method,

we have a service API that we like to use PowerBI to connect to get data where clients and do reporting,

we tried to setup a connection between powerbi desktop and our API through Post request

 

let

body = "{""username"": ""xxxxxxxxx"",""password"": ""xxxxxxx"",""grant_type"": ""password"",""something"": ""test"",""clientsomething"": ""passwordhere"",}",

url = "https://xxxxxxxxxxxx/token",

GetJson = Web.Contents(url,      [

         Headers = [#"Content-Type"="application/x-www-form-urlencoded"],

         Content = Text.ToBinary(body)

     ])

in

GetJson

 

We can get into the api and see some value but what we have problem is  where do I put in the values for individual key and how do I also send in a request body that's recognized by PowerBI? 

Thanks

Hi @v-ljerr-msft,

Thank you for your reply, we did tried to get that in the body,

we still are not able to send in a request body on http post request

at the end that has keys and values (example below)

we need to get a token in response from our authentication service

 

Actual Code: 

 

let 

body = "{""a key here"": ""a value here"",""the next key"": ""password"",""grant_type"": ""password"",""client_id"": ""Test"",""client"": ""password"",}",
url = "https://xxxxxxxx.com/token",
GetJson = Web.Contents(url, [
Headers = [#"Content-Type"="application/x-www-form-urlencoded"],
Content = Text.ToBinary(body)
])
in
GetJson

 

error message we got==> "datasource.error: web.contents failed to get contents" is the error we get, it looks like
 
 

Thank you for your help

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors