Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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 \""
User | Count |
---|---|
98 | |
87 | |
77 | |
67 | |
63 |
User | Count |
---|---|
110 | |
95 | |
95 | |
64 | |
58 |