Forum Discussion
REST API / Invalid JSON Request
- 7 years ago
In the body step of your query, it looks like you're passing a JSON object in the body of the request. A JSON parser would recognize the values for jsonrpc and id as numbers instead of strings. It would also have trouble parsing the value you have for method; it wouldn't recognize it as a string.
I'm not sure what the structure of the request should look like, but it's very likely these values should all be strings.
Try this instead:
let url = "...", bodyContent = [ jsonrpc = "2.0", method = "cmdb.objects.read", params = [apikey = APIKEY], id = "1" ], body = Json.FromValue(bodyContent), Source = Json.Document(Web.Contents(url, [Headers = [#"Content-Type" = "application/json"], Content = body] )) in SourceNote: I assume you have the value for APIKEY defined properly elsewhere.
If that doesn't work, try making the same request with Postman. Also, what does the API documentation say about that -32600 status code?
In the body step of your query, it looks like you're passing a JSON object in the body of the request. A JSON parser would recognize the values for jsonrpc and id as numbers instead of strings. It would also have trouble parsing the value you have for method; it wouldn't recognize it as a string.
I'm not sure what the structure of the request should look like, but it's very likely these values should all be strings.
Try this instead:
let
url = "...",
bodyContent = [ jsonrpc = "2.0", method = "cmdb.objects.read", params = [apikey = APIKEY], id = "1" ],
body = Json.FromValue(bodyContent),
Source = Json.Document(Web.Contents(url, [Headers = [#"Content-Type" = "application/json"], Content = body] ))
in
SourceNote: I assume you have the value for APIKEY defined properly elsewhere.
If that doesn't work, try making the same request with Postman. Also, what does the API documentation say about that -32600 status code?
- Anonymous7 years agoNot applicable
Sorry for the delay and a big thank you tonmcg !!! It works with the square brackets