MPRester.query NOT working

This returns the following for weeks now.

MPRestError: REST query returned with error status code 403

Any help will be appreciated.

What query are you trying to run?

Thanks for your response. Examples of the queries are the following:

  1. get_bandstructure_by_material_id

  2. mpr.query({“pretty_formula”:“SiO2”}, [“material_id”, “structure”])

  3. mpr.query({“pretty_formula”:“SiO2”}, [“material_id”, “formation_energy_per_atom”])

Are you making sure you’re using the MPRester object with your most recent API key? That’s the most common reason MPRester stops working.

Thanks again. It works with the following:

mpr.supported_properties

mpr.get_materials_ids

mpr._make_request(’/battery/all_ids’)

So, I don’t think it has to do with the API key

I should meant, I’m using the keys from mpr.supported_properties.

Examples of which are listed above.

Are those not the most recent keys?

All your queries work fine for me. When I have the wrong API key I get the following error:

REST query returned with error status code 403. Content: b'{"valid_response": false, "error": "API_KEY is not a valid key.", "version": {"db": "2020_09_08", "pymatgen": "2020.8.13", "rest": "2.0"}, "created_at": "2020-11-17T20:28:27.362237"}'

Can you post your full error message? Also, which version of pymatgen are you using?

The pymatgen version is 2020.11.11

I just generated another API key and used and it’s still giving the same error.

I appreciate your time.

I will be delighted to have this resolved.

You have no API key in your MPRester as the error says.
Try something like this:
with MPRester("INSERT_API_KEY_HERE") as mpr:

Great!

Thanks a lot for your time.

with MPRester(“INSERT_API_KEY_HERE”) as mpr:

has solved the problem.