[Python] 400, 404 Errors with Google API Python Client

Discussão em 'Python' iniciado por Stack, Fevereiro 5, 2025.

  1. Stack

    Stack Membro Participativo

    I'm experiencing a couple of issues with the API as I move emails between our application and the users inbox. These issues manifest when I send to a Gmail account from another Gmail account. However, these issues don't seem to manifest when working with an email generated by Google itself. I have samples in JSON format to allow others to reproduce the issue to the GitHub issue I created: https://github.com/google/google-api-python-client/issues/468

    1. I use the "get" request (https://developers.google.com/gmail/api/v1/reference/users/messages/get) to obtain an email and I store it in a PostgreSQL database in two different columns with both raw and full formats.
    2. I use the "delete" request (https://developers.google.com/gmail/api/v1/reference/users/messages/delete) to remove the email from Gmail.
    3. I use use the raw format of the data along with the "insert" request (https://developers.google.com/gmail/api/v1/reference/users/messages/insert) to place the email back into the users inbox. When working with an email sent by Google to a users Gmail account it moves between our software and Gmail without an issue.

    When working with an email I send from my Gmail account to another Gmail account it gives me an error. If I send the JSON format of the email (the full format) I get a 400 error. If I send the raw format of the email I get a 404 not found error.

    Exact Errors:


    404 - https://www.googleapis.com/gmail/v1/users/me/messages?alt=json returned "Not Found"> 400 - https://www.googleapis.com/gmail/v1/users/me/messages?alt=json returned "'raw' RFC822 payload message string or uploading message via /upload/* URL required">
    ​

    I'm using Python3.6 and Google API Client 1.6.4

    Does anyone know if this is a bug in the client software or is there something else I need to consider when using this API to insert emails?

    Continue reading...

Compartilhe esta Página