koalalorenzo/python-digitalocean

Get operations on tags return NotFoundError

ats3v opened this issue · 2 comments

ats3v commented

I get this error pretty consistently both when getting all tags or a single one:

send: 'GET /v2/tags?per_page=200 HTTP/1.1\r\nHost: api.digitalocean.com\r\nConnection: keep-alive\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nUser-Agent: python-requests/2.14.2\r\nAuthorization: Bearer <token>\r\n\r\n'
reply: 'HTTP/1.1 404 Not Found\r\n'
header: Date: Thu, 02 May 2019 12:21:33 GMT
header: Content-Type: application/json; charset=utf-8
header: Transfer-Encoding: chunked
header: Connection: keep-alive
header: Set-Cookie: __cfduid=<...>; expires=Fri, 01-May-20 12:21:33 GMT; path=/; domain=.digitalocean.com; HttpOnly
header: X-Gateway: Edge-Gateway
header: X-Request-Id: <req ID>
header: X-Response-From: service
header: X-Runtime: 0.000337
header: Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
header: Server: cloudflare
header: CF-RAY: <...>
header: Content-Encoding: gzip
DEBUG 2019-05-02 15:21:33,917 10424:connectionpool.py:_make_request:395 : https://api.digitalocean.com:443 "GET /v2/tags?per_page=200 HTTP/1.1" 404 None

Using CURL and following the example in https://developers.digitalocean.com/documentation/v2/#retrieve-a-tag works just fine.

After talking to the DO support, they suspect that not passing Content-Type: application/json in the headers is the problem. This lib passes it only for non get requests.

If you want to try and find a fix for this you are more than welcome. A simple change that ensures the Content Type header might work 🤷‍♂

ats3v commented

I've only done the unit tests and it passes. It needs some more testing.