Forum Discussion
TP-101
2 years agoHelper I
M Query Post REST API, return format not JSON with Expression.Error
I'm attempting a POST to a REST API which should return data in JSON. The POST appears to succeed however, receiving an Expression.Error trying to convert the response to binary. Can this query be ...
lbendlin
2 years agoSuper User
GetJsonQuery = Json.Document(Web.Contents("https://" & Tenant & GetMetric, [Headers=[Authorization=AccessTokenHeader, Accept="application/json"]]))TP-101
2 years agoHelper I
That one is showing a 405 error. I think that might be due to it trying to GET vs. POST without the Content piece.
- lbendlin2 years agoSuper User
yes, didn't notice you had removed that.
GetJsonQuery = Json.Document(Web.Contents("https://" & Tenant & GetMetric, [Headers=[Authorization="AccessTokenHeader", Accept="application/json"], Content=Text.FromBinary(Json.FromValue(data))])) - TP-1012 years agoHelper I
That one put's us back to square 1. Is there something in that line that is trying to convert the returned JSON to binary?
- lbendlin2 years agoSuper User
Sorry, typo again. Tiny screen. Try this one
WebResult = Web.Contents("https://" & Tenant & GetMetric, [Headers=[Authorization=AccessTokenHeader, Accept="application/json"], Content=Text.FromBinary(Json.FromValue(data))]), GetJsonQuery = Json.Document(Text.Replace(Text.Replace(WebResult,"\u000a",""),"\""","""")) - TP-1012 years agoHelper I
Ya, still getting the Expression.Error as before.