Forum Discussion
Call an api with a filter
- 1 year ago
Hi ,
Thanks for reaching out to the Microsoft fabric community forum.
Try to modify the M query into thislet api = url_getEventPending & apiEvent & "/search", token = getTokenData(), idValue = "667995612c15a237078c605e", fullUrl = api & "?id=" & idValue, apiResponse = Web.Contents( fullUrl, [ Headers = [ Authorization = token, #"Content-Type" = "application/json" ] ] ), FormatAsJsonQuery = Json.Document(apiResponse) in FormatAsJsonQuery
and check if you are able to bypass the error.If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thank you - 1 year ago
The error message is telling you that your Content field value needs to be of type binary, but you are instead supplying an M record. Most likely, you can fix this by wrapping your record in Json.FromValue
You can see it in action in example 2 in the MS doc:
https://learn.microsoft.com/en-us/powerquery-m/web-contents#example-2
Hi alops1 ,
Thanks for reaching out to the Microsoft fabric community forum.
There may be an extra closing bracket ] in the code that's affecting the syntax and causing the error. Please review the structure carefully, and let us know if the issue persists after correcting it.
If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thank you
- alops1941 year agoFrequent Visitor
Hi v-nmadadi-msft ,
thanks a lot for the answer but unfortunately that square bracket closes headers and if I remove it the code goes into error.
- v-nmadadi-msft1 year agoCommunity Support
Hi ,
Thanks for reaching out to the Microsoft fabric community forum.
Try to modify the M query into thislet api = url_getEventPending & apiEvent & "/search", token = getTokenData(), idValue = "667995612c15a237078c605e", fullUrl = api & "?id=" & idValue, apiResponse = Web.Contents( fullUrl, [ Headers = [ Authorization = token, #"Content-Type" = "application/json" ] ] ), FormatAsJsonQuery = Json.Document(apiResponse) in FormatAsJsonQuery
and check if you are able to bypass the error.If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thank you
- alops1941 year agoFrequent Visitor
Hi v-nmadadi-msft ,
thanks a lot for the answer but unfortunately that square bracket closes headers and if I remove it the code goes into error.