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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
h4tt3n
Helper V
Helper V

GraphQL query in Power BI?

Hello,

I am trying to connect to a GraphQL api through Power BI and could use some advice. In the Postman API tool I have written a working query, like this:

h4tt3n_0-1599739682395.png

The query is above, and part of the response is below. The URL is a https web address with a single subscription-key parameter.

How do I implement this in Power Query?

Cheers, and thanks in advance, Mike

8 REPLIES 8
Mark_RSantos
New Member

Solução funcional 2024:

let

Source = Web.Contents(

"URL",

[

Headers=[

#"Method"="POST",

#"Content-Type"="application/json",

#"Authorization"= "Bearer xxxxxxxx"

],

Content=Text.ToBinary("{""query"": ""{ cards(pipe_id:xxxxxx){ edges{  node{ id title uuid url phases_history { phase { name created_at } } } } } }""}")

]

),

#"JSON" = Json.Document(Source)

BI_Analyticz
Helper V
Helper V

Have you guys ever tried pagination in this code. Need help for using pagination for retrieving all pages.

amirshiloh
Advocate II
Advocate II

i found a tool that is really helpful from me:  "PowerBI Query Generator for GitHub GraphQL API v4" :

 https://jsfiddle.net/rockyintel/1sqm7dpf/

i entered my graphQL query 

and got the following Power Query M formula which works ! in my query i am using x-api-key as the key name.

this is the output from the generator tool:

let
Source = Web.Contents(
"https://myURL",
[
Headers=[
#"Method"="POST",
#"Content-Type"="application/json",
#"x-api-key"="putMyKeyHere"
],
Content=Text.ToBinary("{""query"": ""{ list{ items{  id name } } }""}")
]
),
#"JSON" = Json.Document(Source),
data = JSON[data]
in
data

Hello, i need the same, but i am a begginner. you can explain me how to connect Graph Ql to Power BI??

Anonymous
Not applicable

For me the following code works: 

Source = Web.Contents(
"http://localhost/HOPEXGraphQL/api/ITPM",
[
Headers=[
#"Method"="POST",
#"Content-Type"="application/json",
#"Authorization"="Bearer " & gottoken,
#"X-Hopex-Context" = "{""EnvironmentId"":""M6LC(Gp3VzSP"",""RepositoryId"":""ihd7)1IVRXR9"",""ProfileId"":""757wuc(SGjpJ""}"
],
// Notice the quote escaping here
Content=Text.ToBinary("{""query"":""query{ application{ id name applicationType businessProcess{ id name} applicationOwner_PersonSystem{ id name } sentApplicationFlow_ApplicationParticipant{ id name } receivedApplicationFlow_ApplicationParticipant{ id name }} }""}")
]
),
#"JSON" = Json.Document(Source),
data = JSON[data]

Anonymous
Not applicable

Hello,

Would like to ask if you are still using Power BI and GraphQL? Does it still work after 2 years with the new verision of Hopex V5. We are trying to do the same thing that you are doing and coincidentally we are using Hopex GraphQL as well. Still did not manage to make it work. Would really appreciate it if you would send the code you are using to connect them.

Thank you!

ibarrau
Super User
Super User

Hi. You can try this. Assuming the response is a json. Imagine this is your URL: "https://swapi.dev/api/people/?search=Skywalker" and the body is a simple json with two params.

Then the code might be like this:

let
Json_body = Json.FromValue("{ ""first_param"": ""AAAAA"",  ""second_param"": ""BBBBBB""}",),
Source = Json.Document(Web.Contents("https://swapi.dev/api/", [
    RelativePath="people/",
    Query=[search="Skywalker"],
    Headers=[#"Content-Type"="application/json"], 
    Content=Json_body
]))
in
Source

Hope it helps.


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Greg_Deckler
Super User
Super User

@ImkeF @edhans 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors