Closed j3dd3rs closed 4 years ago
@j3dd3rs Thanks for providing such a detailed bug report.
The cause of the issue is MyChem contain huge amount of data about Carbamazepine, and the query you send to MyChem ask to retrieve all of the data about it. Due to the (tremendous) size of the transfer data, the server closes its connection before the transfer completes. That's why you're seeing the error message. For propranolol which succeeds, it's because it contains less data.
To circumvent this issue, MyChem actually allow you to specify a fields parameter which limits the size of the document returned (so that the transfer data could be smaller). For example, if you only want to retrieve data about Carbamazepine from CHEMBL and DrugBank in MyChem, you can do a query like this: https://mychem.info/v1/chem/FFGPTBGBLSHEPO-UHFFFAOYSA-N?fields=chembl,drugbank. And for all fields available in MyChem, you can refer to the link here.
That would make sense then. I only asked as it has been working for months and then stopped working. So wasn't sure what was going on with it in the end but I can shorten my queries to make it work better in that case. Thanks for the advice on why it isn't working.
Improved on server side. The original access should work again. Thank you for bringing this into our attention.
Yesterday I noticed my code wasn't working but I had been playing around with my development version and assumed it was me. But then I used my live hosted code which had not been touched and it was not liking my API request. I have been using python with the requests library and got this error:
From this I assumed my code just was timing out or something. But then I tried to do it via a web browser to confirm it wasn't my code. But I ended up with an error about the JSON not parsing properly for the chemical Carbamazepine (https://mychem.info/v1/chem/FFGPTBGBLSHEPO-UHFFFAOYSA-N). The error for this particular endpoint was:
SyntaxError: JSON.parse: unterminated string literal at line 1 column 667835 of the JSON data
What added to my confusion is that this endpoint of propranolol, https://mychem.info/v1/chem/AQHHHDLHHXJYJD-UHFFFAOYSA-N, did work. So maybe one of the sources not present in the other endpoint is having an issue where as this doesn't?
I also tried both in the live API on the website to confirm it wasn't any connections I had. For the Carbamazepine it gave this result:
For the 2nd one, Propranlol, it did work and gave me the data:
It could be just an issue with one of the other APIs being down? But I don't know from what it gives me what is going on.