Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch List create and delete raising errors #224

Open
dFHcqXxdCludWt opened this issue Nov 16, 2021 · 0 comments
Open

Watch List create and delete raising errors #224

dFHcqXxdCludWt opened this issue Nov 16, 2021 · 0 comments

Comments

@dFHcqXxdCludWt
Copy link

There are two errors I discovered in client.py

  1. create_watchlist function I needed to change the _make_request call, previously it was using PUT and data=payload, this was throwing strange errors. the new code I used is _return self.make_request(method='post', endpoint=endpoint, mode='json', json=payload,order_details=False)
  2. _make_request function I needed to check for additional response codes and non-json responses for example delete_watchlist returns a 204 with nobody - below is the code that I added into the _make_request function. PS print statements are for testing.

If it's okay and no details.

    elif response.ok:

        json_content_type = False
        try :
            json_content_type = response.headers["content-type"].strip().startswith("application/json")
        except KeyError :
            json_content_type = False
        if (
                response.status_code != 204 and
                json_content_type
        ):
            try:
                return response.json()
            except ValueError:
                raise ValueError
                # decide how to handle a server that's misbehaving to this extent
        else:
            print("response.status_code : " + str(response.status_code))
            print("response headers" + str(response.headers))
            print("response json" + str(response.request.body))
            response_dict = {
                'headers': response_headers,
                'content': response.content,
                'status_code': status_code,
                'request_body': response.request.body,
                'request_method': response.request.method
            }
            print (response_dict)
            return response_dict

    else:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant