cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
wabanek Frequent Visitor
Frequent Visitor

Use cURL in PowerBi

Is it possible to connect dataset via cURL to PowerBI ?

I have cURL generate by graphql but not sure i I can use it somehow in PB

 

curl 'https://api.com/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: https://api.com' -H 'access_token: ' --data-binary '{"query":"# Write your query or mutation here\n{\n members{\n data{\n user{\n name\n }\n }\n }\n}\n"}' --compressed

 

4 REPLIES 4
wabanek Frequent Visitor
Frequent Visitor

Re: Use cURL in PowerBi

So far I managed to create below m code but i doesnt work. Im newbie to M language, can someone support me with it?

 

let
    apiUrl = "https://apiname.com/graphql",
    options = 
        [Headers =[#"Content-Type"="application/json", #"Subscription-Key"="<my token>"],
        Content = Text.ToBinary({"query:{\n  members{\n    data{\n      user{\n        name\n      }\n    }\n  }\n}\n"})
    ],
    Content = options[Content]
in
    Content

Error message: We cannot converte List type to Text type

 

Community Support Team
Community Support Team

Re: Use cURL in PowerBi

Hi @wabanek 

Do you want to connect to the Microsoft Graph Security API?

If so, please follow this this article to use the Microsoft Graph Security connector of Power BI Desktop.

 

If you'd like to connect to your secure API like this article

In the editor, enter the API’s address and any header information needed for that api.

After this, when a warning message pops up, Click “Edit Credentials”

let

     apiUrl = "https://xxxxxxx/api/info",

     options = [Headers =[#"Subscription-Key"="xxxxxxxxxxxxxxxxxxxxx"]],

     result = Web.Contents(apiUrl , options)

in

     result

 

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

wabanek Frequent Visitor
Frequent Visitor

Re: Use cURL in PowerBi

Thanks Maggie for you reply. I'm Trying to connect to secure Api, tried your step and not sure how to move further, could you advise

 

Przechwytywanie.PNG

wabanek Frequent Visitor
Frequent Visitor

Re: Use cURL in PowerBi


Hi Again, 

 

Could you check below why Im getting below error?

 

Przechwytywanie.PNG



let Source = Web.Contents( "https://api.com/graphql", [ Headers=[ #"Method"="POST", #"Content-Type"="application/json", #"Authorization"="Origin: https://api.com' -H 'access_token: <my token>" ], // Notice the quote escaping here Content=Text.ToBinary("{""query"":""{ invoices{data{number}}}""}") ] ), #"JSON" = Json.Document(Source) in #"JSON"
curl 'https://api.com/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: https://api.com' -H 'access_token: <my token>' --data-binary '{"query":"# Write your query or mutation here\n\n{\n  invoices{\n    data {\n      number\n      \t}\n      \n    }\t\n  }\n\n"}' --compressed