Gmail REST api batch support for getting messages

后端 未结 3 1643
深忆病人
深忆病人 2020-12-11 19:11

We need to switch from google client library to Gmail REST api in our project, and I\'ve encountered a problem with batch() because it is not available in REST api - you can

3条回答
  •  一生所求
    2020-12-11 19:37

    • You need to include gmail/v1 on the POST URL and on each request.
    • Don't forget about the " around your boundary on the Content-Type header.

    See original batch gmail requests documentation: https://developers.google.com/gmail/api/guides/batch

    The following worked for me:

    POST /batch/gmail/v1 HTTP/1.1
    Host: www.googleapis.com
    Authorization: Bearer {YOUR_ACCESS_TOKEN}
    Content-Type: multipart/mixed; boundary="foo_bar"
    
    --foo_bar
    Content-Type: application/http
    
    GET /gmail/v1/users/me/messages/1732ebdcb9b8cccf
    --foo_bar
    Content-Type: application/http
    
    GET /gmail/v1/users/me/messages/1732ecadae4907e2
    
    --foo_bar--
    

    Creating request with Postman - body screenshot

    Creating request with Postman - headers screenshot

提交回复
热议问题