linode.errors.ApiError: 400: Invalid JSON; from null json
See original GitHub issueHello!
Not really sure if this is a problem with the api-wrapper or the actual api itself since this error just started happening today and I haven’t upgraded the wrapper since I last ran the same script successfully. Either way, when I use get_instances I get a stacktrace;
>>> c = linode.LinodeClient(supersecretkeygoeshere)
>>> linodes = c.linode.get_instances(linode.Linode.label == 'name of a linode')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/emil/code/jenkins-scripts/env/lib/python2.7/site-packages/linode/linode_client.py", line 31, in get_instances
return self.client._get_and_filter(Linode, *filters)
File "/Users/emil/code/jenkins-scripts/env/lib/python2.7/site-packages/linode/linode_client.py", line 656, in _get_and_filter
return self._get_objects(obj_type.api_list(), obj_type, filters=parsed_filters)
File "/Users/emil/code/jenkins-scripts/env/lib/python2.7/site-packages/linode/linode_client.py", line 487, in _get_objects
response_json = self.get(endpoint, model=model, filters=filters)
File "/Users/emil/code/jenkins-scripts/env/lib/python2.7/site-packages/linode/linode_client.py", line 503, in get
return self._api_call(*args, method=requests.get, **kwargs)
File "/Users/emil/code/jenkins-scripts/env/lib/python2.7/site-packages/linode/linode_client.py", line 477, in _api_call
raise ApiError(error_msg, status=response.status_code, json=j)
linode.errors.ApiError: 400: Invalid JSON;
After digging down in linode_client.py it seems like the problem happens when the client sends empty json to the api:
def _api_call(self, endpoint, model=None, method=None, data=None, filters=None):
....
body = json.dumps(data) # evaluates to null if data is omitted/None
response = method(url, headers=headers, data=body)
I did a simple hack to get everything up and running again (check if data is None and if it is don’t send the body through method() and that works but feels pretty hackish.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How do i add a linode instanc using API in windows command ...
Hi, I am trying to create a linode using the linode instance API.. curl -v POST "https://api.linode.com/v4/linode/instances" -H ...
Read more >Getting error {{'code': 400, 'message': 'Invalid JSON payload ...
I am trying to run the following code for googleautoreply but it is giving the error 'Invalid JSON payload received.
Read more >Error Code 400: Invalid json message received #1190 - GitHub
Today i've upgraded to 3.4 and as soon as i Post Parameters with the Sandbox i receive a Error 400 - Invalid json...
Read more >REST API - "Error: Request is not valid JSON" Status Code: 400
Hi UIPathians, After reading through tons of posts on REST API calls on the forum, still unable to figure out a reason for...
Read more >Error in Invalid JSON - SymfonyCasts
To make this a 400 error, we could do 2 things. First, we could create a new Response object and set its status...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is fixed in version
4.1.8b1
. Apip install --upgrade linode-api
should get it up and running again. Sorry for the inconvenience.Thanks for reporting this, I’m looking into it now