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!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live 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 \""
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
| User | Count |
|---|---|
| 52 | |
| 41 | |
| 32 | |
| 26 | |
| 24 |
| User | Count |
|---|---|
| 131 | |
| 118 | |
| 57 | |
| 45 | |
| 43 |