How batch api for gmail can be used for listing gmail?

Want to make a batch request for listing that can bring sender and title of each message along with it in gmail api. how can I make a batch request for it? Is it possible to make a batch request using postman?

As part of batch request, how batch request can be requested ?

how can I use batch request for above requirement endpoints?

As part of batch request as per google doc ,
POST /batch/farm/v1 HTTP/1.1
Authorization: Bearer your_auth_token
Host: www.googleapis.com
Content-Type: multipart/mixed; boundary=batch_foobarbaz
Content-Length: total_content_length

--batch_foobarbaz
Content-Type: application/http
Content-ID: <item1:12930812@barnyard.example.com>

GET /farm/v1/animals/pony

--batch_foobarbaz
Content-Type: application/http
Content-ID: <item2:12930812@barnyard.example.com>

PUT /farm/v1/animals/sheep
Content-Type: application/json
Content-Length: part_content_length
If-Match: "etag/sheep"

{
  "animalName": "sheep",
  "animalAge": "5"
  "peltColor": "green",
}

--batch_foobarbaz
Content-Type: application/http
Content-ID: <item3:12930812@barnyard.example.com>

GET /farm/v1/animals
If-None-Match: "etag/animals"

--batch_foobarbaz--

as per my requirement, I don't get how doc request can be modified?

1 answer

  • answered 2019-09-12 06:40 DaImTo

    How can I make a batch request for it?

    By using the batching end point Batching

    Is it possible to make a batch request using postman?

    Yes postman can handle this call. But you will have to manually create the body which considering can contain 100 requests is going to be very time consuming and pron to error IMO.

    As part of batch request, how batch request can be requested ?

    By sending a HTTP Post where the body contains each of the single requests you are requesting data for.

    how can I use batch request for above requirement endpoints?

    You can do it with postman or any other programming language that can handle http post calls.

    each line GET /farm/v1/animals in the body contains the request that you wish to make to the api in your case it would be something like users/me/messages/1.

    You will need to call users messages.list first get a list of all the message ids that you want to get information for. Then build up your batch request to the user.messages to get and request each message. Batching will not mean that you dont need to send a get request for each message batching just saves you the extra http calls made by sending each get request.

    POST /batch/gmail/v1 HTTP/1.1
    Authorization: Bearer your_auth_token
    Host: www.googleapis.com
    Content-Type: multipart/mixed; boundary=batch_foobarbaz
    Content-Length: total_content_length
    Accept-Encoding: application/gzip
    
    --batch_foobarbaz
    Content-Type: application/http
    
    
    GET gmail/v1/users/me/messages/16d24956228a98c4
    Accept: application/json; charset=UTF-8
    
    --batch_foobarbaz
    Content-Type: application/http
    
    
    GET gmail/v1/users/me/messages/16d24956228a98c4
    Accept: application/json; charset=UTF-8
    
    --batch_foobarbaz--