413 - Request Entity Too Large

前端 未结 1 370
心在旅途
心在旅途 2020-12-11 19:21

I can upload small drafts OK using the metadata endpoint (https://www.googleapis.com/gmail/v1/users/me/drafts), e.g.:

{\"message\":{\"raw\":\"TUlNRS1WZXJzaW9         


        
相关标签:
1条回答
  • 2020-12-11 19:57

    You need to use the /upload "media upload" path to upload anything over a few MB. The URL and POST format are slightly different:

    You'd do:

    1. POST https://www.googleapis.com/upload/gmail/v1/users/userId/drafts
    2. add a HTTP header like "Content-type: multipart/related; boundary=\"part_boundary\""
    3. POST body looks more like:
    --part_boundary
    Content-Type: application/json; charset=UTF-8
    
    {
    }
    
    --part_boundary
    Content-Type: message/rfc822
    
    From: script@example.org
    To: user@example.com
    Subject: test
    
    body here
    
    --part_boundary--
    

    See this for more info (which then links to this).

    0 讨论(0)
提交回复
热议问题