Empty request body


#1

I see someone else had this same issue but their solution does not apply to my case.

I am trying to push data to a bar chart and have used the “simple” example to test my code but I get a 400 error with the message empty request body.

Anyone able to point me in the direction of what I may be missing?

The json body I used (from the example) looks like this

{
“api_key”: “somekey”,
“x_axis”: {
“labels”: [“open”, “pending”, “solved”, “closed”]
},
“series”: [
{
“data”: [45, 4, 251, 554]
}
]
}

TIA


#2

Turns out I worked out how to use the datasets API and it works so don’t need to solve this one anymore.


#3

Hi there @ausmarkb,

It looks like you’re sorted now with Datasets, but (just in case you’re curious or would like to use Custom Widgets again some time in the future), I did a test with your code and figured out where things were going wrong. :slight_smile:

It looks like you were missing the "data": element used to push the bar chart contents to the widget so that we were encountering "x_axis": and not understanding what to do with it.

Here’s what the JSON body should have looked like:

{
"api_key":"somekey",
"data":{
"x_axis": {
"labels": ["open", "pending", "solved", "closed"]
},
"series": [
{
"data": [45, 4, 251, 554]
}
]
}
}

I tested this with a widget in my own account and it definitely worked but if you do give this a try and run into more problems, just let me know.

I hope this helps!

Lisa


#4

Thanks. I saw something similar in an earlier post but I though it didn’t apply because I had the data array below series.
Probably should have tried it anyway :smirk: