IHTSDO / SNOMED-in-5-minutes

Easy-to-use tutorials for accessing SNOMED APIs within 5 min using various programming languages
Other
123 stars 56 forks source link

Solving HTTP Error 423 for Python3 Agent #34

Closed KimBenjaminTang closed 9 months ago

KimBenjaminTang commented 1 year ago

I also encountered the HTTP Error 423 mentioned in the already existing issue: https://github.com/IHTSDO/SNOMED-in-5-minutes/issues/30 With this adjustment the issue can be fixed.

pgwilliams commented 1 year ago

Thank you for this PR, @KimBenjaminTang We're going to have a discussion here about our handling of the HTTP User-Agent header. I'll let you know what the outcome of that is.

sxaxmz commented 1 year ago

Hi, As mentioned earlier.

I ran the sample code for Python and ended up with the same error, any updates?

HTTPError                                 Traceback (most recent call last)
[<ipython-input-16-165e637bf904>](https://localhost:8080/#) in <cell line: 1>()
----> 1 getConceptById('109152007')
      2 getDescriptionById('679406011')
      3 getConceptsByString('heart attack')
      4 getDescriptionsByStringFromProcedure('heart', 'procedure')
      5 

7 frames
[/usr/lib/python3.9/urllib/request.py](https://localhost:8080/#) in http_error_default(self, req, fp, code, msg, hdrs)
    639 class HTTPDefaultErrorHandler(BaseHandler):
    640     def http_error_default(self, req, fp, code, msg, hdrs):
--> 641         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    642 
    643 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 423:

Changing works:

req.add_header('User-Agent','Python3')

to

req.add_header('User-Agent','Python')