Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Good morning every one I have a GraphQL query that I've turned into an M Script but I'm having issues in taking an "error" out the script reads as follows:
let
endpoint = "https://your-graphql-endpoint",
client_id = "your-client-id",
client_secret = "your-client-secret",
graphqlQuery = "query orders($regionCode: String!, $licenseNumber: String, $order: [OrderSortInput!], $where: OrderFilterInput) {
orders(regionCode: $regionCode, licenseNumber: $licenseNumber, order: $order, where: $where) {
items {
vendor {
name
licenseNumber
}
lineItems {
product {
strain {
name
}
categoryName
}
quantity
price
total
}
createTimestamp
}
}
}",
graphqlVariables = "{
\"regionCode\": \"wa\",
\"licenseNumber\": \"123456\",
\"order\": [{ \"poNumber\": \"DESC\" }],
\"where\": { \"updateTimestamp\": { \"gte\": \"2023-07-10\" } }
}",
tokenBody = [
grant_type = "client_credentials",
client_id = client_id,
client_secret = client_secret
],
tokenResponse = Json.Document(Web.Contents("https://your-auth-endpoint/token", [
Content = Text.ToBinary(Uri.BuildQueryString(tokenBody)),
Headers = [#"Content-Type"="application/x-www-form-urlencoded"]
])),
accessToken = tokenResponse[access_token],
headers = [
Authorization = "Bearer " & accessToken,
#"Content-Type" = "application/json"
],
body = [
query = graphqlQuery,
variables = graphqlVariables
],
result = Json.Document(Web.Contents(endpoint, [
Content = Text.ToBinary(Json.FromValue(body)),
Headers = headers
]))
in
result
I'm getting the error in this section:
and the error is saying this:
I've tried to rewrite this in so many ways but im still getting the same error.
Any help on how to rewrite this would be awesome or any of connector solutions that would be easier to deal with instead of inputting this into the M Script would be helpful as well.
Thanks to all that help.
you need to double escape. Instead of \" you need to use \""
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 65 | |
| 49 | |
| 42 | |
| 25 | |
| 22 |
| User | Count |
|---|---|
| 143 | |
| 118 | |
| 56 | |
| 37 | |
| 31 |