[Python] Updating requests from version 2.31.0 to 2.32.3 breaks my code

Discussão em 'Python' iniciado por Stack, Março 16, 2025.

  1. Stack

    Stack Membro Participativo

    I have some code that uses the requests library to access some grid information from the Spanish electric system. There is open access if you ask for an API key. I created the code under the 2.31.0 version of requests, using the following call:

    import requests
    url = 'https://api.esios.ree.es/indicators/1002'
    api_key = 'my_apy_key'
    headers = headers = {
    'Accept':'application/json; application/vnd.esios-api-v2+json',
    'Content-Type':'application/json','Host':'api.esios.ree.es',
    'x-api-key': api_key}
    params = {'start_date': '2025/03/01T00', 'end_date': '2025/03/12T23'}

    resp = requests.get( url, headers=headers, params = params)


    This, which still works under 2.31.0, returns a 403 when updating requests. I have no idea what is the change. I have very important code which requires this to work, and I would at least like to know what could I do if updating requests at some point is absolutely necessary. Any ideas?

    Continue reading...

Compartilhe esta Página