cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Belvedere90
Frequent Visitor

REST API / Invalid JSON Request

Hello everyone,

i am trying to connect the Power BI Client to a REST API by a Dataset.

The Dataset i am tryin to run, looks like this:

 

1pbi.jpg

 

I alway get the error, that says, this is an invalid request.2pbi.jpg

I dont get what there is been missing or where the error is? I didnt find anything through researches.

Am I Missing the Authentification (X-RPC-Auth-Username / X-RPC-Auth-Password / X-RPC-Auth-Session)?

If yes, where do i have to insert it?

 

I am very thankful for your help,

Regards

1 ACCEPTED SOLUTION

Accepted Solutions
tonmcg Resolver II
Resolver II

Re: REST API / Invalid JSON Request

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
    Source

Note: 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?

 

View solution in original post

2 REPLIES 2
tonmcg Resolver II
Resolver II

Re: REST API / Invalid JSON Request

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
    Source

Note: 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?

 

View solution in original post

Belvedere90
Frequent Visitor

Re: REST API / Invalid JSON Request

Sorry for the delay and a big thank you tonmcg !!! It works with the square brackets

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors