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

Unable to access the URL getting error code 423 #30

Closed yashwanth-csi closed 2 years ago

yashwanth-csi commented 2 years ago

While accessing the code from python I'm facing below error :

Traceback (most recent call last): File "C:\Users\yvallabhaneni\PycharmProjects\Metaiq_Categories\test.py", line 49, in getConceptsByString('covid') File "C:\Users\yvallabhaneni\PycharmProjects\Metaiq_Categories\test.py", line 34, in getConceptsByString response = urlopen_with_header(url).read() File "C:\Users\yvallabhaneni\PycharmProjects\Metaiq_Categories\test.py", line 13, in urlopen_with_header return urlopen(req) File "C:\Users\yvallabhaneni\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 214, in urlopen return opener.open(url, data, timeout) File "C:\Users\yvallabhaneni\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 523, in open response = meth(req, response) File "C:\Users\yvallabhaneni\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 632, in http_response response = self.parent.error( File "C:\Users\yvallabhaneni\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 561, in error return self._call_chain(args) File "C:\Users\yvallabhaneni\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain result = func(args) File "C:\Users\yvallabhaneni\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 641, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 423:

Please help me with this.

kaicode commented 2 years ago

@rorydavidson it looks like clients with "User-Agent: Python3" are being blocked from the public Snowstorm instance. Do you have a recommendation here?

mgraauw commented 2 years ago

Changing line #12 to req.add_header('User-Agent','Python') works

yashwanth-csi commented 2 years ago

Thank you so much. Its works after changing the line #12.