MPRestError: REST query returned with error status code 404 on URL

hello. I was able to run successful code yesterday, but returned 404 today. I then tried using the official sample code, but it returned 404 as well. What’s causing it in this case, my network should be fine


Please update to the latest mp-api client version

Thank you very much. The update solved the problem, which really helped me a lot

Hi developers,

I believe I have already updated to the latest version, but I still encounter the same error when running the code above.

Do you have any idea what is the problem ?

Thanks.

Since the request is going to /thermo and not /materials/thermo, you likely still have an old version of the mp-api client. Double-check in your python shell, via

from mp_api.client import __version__
print(__version__)

or, in your bash/zsh/…, via

pip freeze | grep mp-api

The version should be 0.33.1. If not, make sure to upgrade the client in the right python environment via pip install -U mp-api

2 Likes

Thank you so much! Works well now.

Hi,
I tried to upgrade mine using the commands given, but my mp-api is still version
0.18.0

You might have to upgrade your python version

Hello tschaume,

I faced the same problem and solved it by updating mp-api.

I registered today and just want to say, thank you so much for your answers.

Best wishes

1 Like

Hi. I have updated my python version to 10 and I did pip install -U mp-api and the version shows mp-api==0.33.3. However, I am trying to run a piece of code to see if my API key works and grab the information from the database.
##Code
from mp_api.client import MPRester
with MPRester(“MY_API_KEY”) as mpr:
docs = mpr.materials.search(material_ids=[“mp-149”, “mp-13”, “mp-22526”])

Sorry I forgot to add my error. I am getting the same problem.
MPRestError: REST query returned with error status code 404 on URL https://api.materialsproject.org/materials/?material_ids=mp-149&material_ids=mp-13&material_ids=mp-22526&all_fields=True&limit=1000 with message:
Not Found

The URL in the error messages indicates that upgrading mp-api hasn’t actually gone through for you. Make sure you’re using the right python environment that contains the latest mp-api version.

Thank you for your responses.

The diffpycmi library that I am utilizing for my research currently requires Python 3.7. However, I have discovered that the new API key and the import statement “from mp_api.client import MPRester” are compatible with newer Python versions such as 3.9. Shifting our project from the legacy API is essential for two reasons. Firstly, the legacy API will eventually be retired, making it necessary to update our codebase. Secondly, if we continue to use “from pymatgen.ext.matproj import MPRester,” our queries are no longer functioning from June 16.

Unfortunately, during my attempts to transition to the legacy API, I encountered an error: “MPRestError: REST query returned with error status code 403. Content: b’{“valid_response”: false, “error”: “Invalid request method.”, “version”: {“db”: “2020_09_08”, “pymatgen”: “2022.0.8”, “rest”: “2.0”}, “created_at”: “2023-06-23T08:49:14.598637”}'.” This error has hindered the execution of our queries.

Point to be noted: I updated my new API from the materials project.

I am actively working to resolve this issue and ensure the smooth functioning of my research. If you have any insights or suggestions regarding this matter, I would greatly appreciate your input. Is there any way I can make the New API client work on my python 3.7 environment?

@Farman_Sayem thanks for reaching out. There’s a separate ongoing thread regarding the specific 403 error you face. We’re trying to narrow it down over there, and would appreciate any helpful feedback you could add.

As for the new API client supporting python 3.7, that’s highly unlikely (@munrojm). End of life for python 3.7 is tomorrow which means that the developers of diffpycmi would really need to consider moving to a newer python version asap.

Thread closed due to inactivity, please open a new thread to address related issues.