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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

GraphQL Post query to Power Query format

Hi all,

 

I am trying to convert the following GraphQL post query to a format that is supported by Power Query:

 

 

 

{
  people(first: 100, view: all, filter: {id: {values:"123456789ABC"}}) {
    nodes {
      id
      name
      primaryEmail
      contacts(first: 100) {
        nodes {
          label
          uri
        }
      }
    }
  }
}

 

 

 

 

Without the ID filter, I am able to get this to work. However, I want to be able to filter directly on an ID (this will be replaced by a variable later, called PersonID). At the moment, I have:

 

 

 

//(PersonID as text) as table =>
let
    vUrl = "https://graphql.###.com/",
    vHeaders =[
			#"Method"="POST",
			#"Content-Type"="application/json",
			#"Authorization"="Bearer 12345ABC"
		],
    // Notice the quote escaping here
    vContent=Text.ToBinary("{""query"": ""{people(first: 100, view: all) {nodes {id name primaryEmail contacts(first:100){nodes {label uri}}}}}""}"),
    Source = Web.Contents(vUrl,	[Headers=vHeaders, Content=vContent]),

 

 

 

My idea was to get it to work the following way:

 

 

 

(PersonID as text) as table =>
let
    vUrl = "https://graphql.###.com/",
    vHeaders =[
			#"Method"="POST",
			#"Content-Type"="application/json",
			#"Authorization"="Bearer 1234ABC"
		],
    // Notice the quote escaping here
    vContent=Text.ToBinary("{""query"": ""{people(first: 100, view: all, filter: {id: {values:123456789ABC}}) {nodes {id name primaryEmail contacts(first:100){nodes {label uri}}}}}""}"),
    Source = Web.Contents(vUrl,	[Headers=vHeaders, Content=vContent]),
    #"JSON" = Json.Document(Source)
in
    #"JSON"

 

 

 

 This returns an error, however: Argument 'values' on InputObject 'IDFilter' has an invalid value (123456789ABC). Expected type '[ID!]!'.

 

Other variations on filtering the ID has only given me HTTP 400 errors. 

 

I hope anyone can help me out! 🙂

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I have found the solution. The fix was to add two backslashes around the ID, as follows:

 

//(PersonID as text) as table =>
let
    vUrl = "https://graphql.###.com/",
    vHeaders =[
			#"Method"="POST",
			#"Content-Type"="application/json",
			#"Authorization"="Bearer 1234ABC"
		],
    // Notice the quote escaping here
    vContent=Text.ToBinary("{""query"": ""{people(first: 100, view: all, filter: {id: {values:\""123456789ABC\""}}) {nodes {id name primaryEmail contacts(first:100){nodes {label uri}}}}}""}"),
    Source = Web.Contents(vUrl,	[Headers=vHeaders, Content=vContent]),
    #"JSON" = Json.Document(Source)
in
    #"JSON"

 

As a function:

(PersonID as text) as table =>
let
    vUrl = "https://graphql.###.com/",
    vHeaders =[
			#"Method"="POST",
			#"Content-Type"="application/json",
			#"Authorization"="Bearer 1234ABC"
		],
    // Notice the quote escaping here
    vContent=Text.ToBinary("{""query"": ""{people(first: 100, view: all, filter: {id: {values:\""" & PersonID & "\""}}) {nodes {id name primaryEmail contacts(first:100){nodes {label uri}}}}}""}"),
    Source = Web.Contents(vUrl,	[Headers=vHeaders, Content=vContent]),
    #"JSON" = Json.Document(Source)
in
    #"JSON"

 

View solution in original post

4 REPLIES 4
Natialuk
New Member

Hi, I tried to use the format but didn't manage to convert it to Power Query. Can someone please assist with translating the following GraphQL query:

query {
  courseProgress {
    nodes {
      user{email}
            courseId
            courseIdNum
            percentComplete
            isCourseCompleted
            completedOn
            courseSeconds
            totalWatchedSeconds
            totalClipsWatched
            firstViewedClipOn
            lastViewedClipOn
            planId
            updatedOn
    }
  }
}
Anonymous
Not applicable

I have found the solution. The fix was to add two backslashes around the ID, as follows:

 

//(PersonID as text) as table =>
let
    vUrl = "https://graphql.###.com/",
    vHeaders =[
			#"Method"="POST",
			#"Content-Type"="application/json",
			#"Authorization"="Bearer 1234ABC"
		],
    // Notice the quote escaping here
    vContent=Text.ToBinary("{""query"": ""{people(first: 100, view: all, filter: {id: {values:\""123456789ABC\""}}) {nodes {id name primaryEmail contacts(first:100){nodes {label uri}}}}}""}"),
    Source = Web.Contents(vUrl,	[Headers=vHeaders, Content=vContent]),
    #"JSON" = Json.Document(Source)
in
    #"JSON"

 

As a function:

(PersonID as text) as table =>
let
    vUrl = "https://graphql.###.com/",
    vHeaders =[
			#"Method"="POST",
			#"Content-Type"="application/json",
			#"Authorization"="Bearer 1234ABC"
		],
    // Notice the quote escaping here
    vContent=Text.ToBinary("{""query"": ""{people(first: 100, view: all, filter: {id: {values:\""" & PersonID & "\""}}) {nodes {id name primaryEmail contacts(first:100){nodes {label uri}}}}}""}"),
    Source = Web.Contents(vUrl,	[Headers=vHeaders, Content=vContent]),
    #"JSON" = Json.Document(Source)
in
    #"JSON"

 

Icey
Community Support
Community Support

Hi @Anonymous ,

 

I know little about GraphQL Post query. Just one speculation:

 

Does the issue caused by the absence of double quotes of id value?

(PersonID as text) as table =>
let
vUrl = "https://graphql.###.com/",
vHeaders =[
#"Method"="POST",
#"Content-Type"="application/json",
#"Authorization"="Bearer 1234ABC"
],
// Notice the quote escaping here
vContent=Text.ToBinary("{""query"": ""{people(first: 100, view: all, filter: {id: {values:"123456789ABC"}}) {nodes {id name primaryEmail contacts(first:100){nodes {label uri}}}}}""}"),
Source = Web.Contents(vUrl, [Headers=vHeaders, Content=vContent]),
#"JSON" = Json.Document(Source)
in
#"JSON"

 

In addition, here is a document about GraphQL API + PowerBI Integration. Hope it helps.

 

 

Best Regards,

Icey

 

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

Anonymous
Not applicable

Hi Icey,

 

Thanks for your input. I've a couple of variations with quotes, resulting in the following:

 

id: {values:""123456789ABC""} > HTTP 400 error

id: {values:"123456789ABC"} > Token comma expected

id: {values:'123456789ABC'} > Parse error on "'" (error) at [1, 53]

id: {values:123456789ABC} > Argument 'values' on InputObject 'IDFilter' has an invalid value (123456789ABC). Expected type '[ID!]!'.query.png

 

As you can see, nothing will work 😞

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.