Forum Discussion
GET Request and Token authentication to download file as JSON
Hello Community,
I have very minimal knowledge on APIs . I got a request from one of the clients to design a report . However, they said we should get data from JSON as data source. They just provided me a link as shown in screenshot.
They said We need to Post a GET command and also provided a Token for authentication purpose. By downloading file in JSON format , we can get use data option from Power BI for JSON and use data.
However, I am not able to download file . Could some one please suggest how to get data from the link and token code provided below .''
Query parameters and header information can be part of the Web.Contents call. The last URL shows the examples.
https://docs.microsoft.com/en-us/powerquery-m/web-contents
https://docs.microsoft.com/en-us/power-query/web.contents
https://kohera.be/blog/power-bi/the-hidden-gems-of-the-function-web-contents/
- Anonymous6 years ago
Hi Anonymous,
You can try to use the following code if it meets your requirement:
let GetJson = Web.Contents( "https://xxxxxxxx/api", [ RelativePath="/v1.0/data/search", Query= [ query="xxxxxxx", limit=1000 ] ] ), FormatAsJson = Json.Document(GetJson) in FormatAsJsonReference links:
Using The RelativePath And Query Options With Web.Contents() In Power Query And Power BI M Code
Get Data from Twitter API with Power Query
Regards,
Xiaoxin Sheng
6 Replies
- lbendlinSuper User
in Power Query use the "from Web" data source dialog which translates into Web.Contents(<url>,[<parameters]). Once you have the raw data you can open it with JSON.Document() etc.
"We need to Post a GET command" - this made me chuckle - thank you.
- AnonymousNot applicableHi, Thanks for the help. I knew that my question will make you laugh. But i am picking this up for the first time. I managed to insert the URL and this is hw it looks. let Source = Web.BrowserContents("https://addm-dc.lowes.com/") in Source Could you please help me how to provide token information as well ? I am looking for M-query similar to the code shown above.
- AnonymousNot applicable
Hi Anonymous,
You can try to use the following code if it meets your requirement:
let GetJson = Web.Contents( "https://xxxxxxxx/api", [ RelativePath="/v1.0/data/search", Query= [ query="xxxxxxx", limit=1000 ] ] ), FormatAsJson = Json.Document(GetJson) in FormatAsJsonReference links:
Using The RelativePath And Query Options With Web.Contents() In Power Query And Power BI M Code
Get Data from Twitter API with Power Query
Regards,
Xiaoxin Sheng