Reputation: 188
I'm try to send email using google gmail API. I've used Request body JSON with bearer token and Content-Type - message/rfc822.
Then I've used link below to send post request but I received the following errors.how to fix this issue ???
Post request Link -
https://www.googleapis.com/upload/gmail/v1/users/[email protected]/messages/send
Request Body
{
"threadId": "Hi kasunjith",
"payload": {
"mimeType": "message/rfc822",
"headers": [
{
"name": "To",
"value": "[email protected]"
},
{
"name": "From",
"value":"[email protected]"
},
{
"name":"Subject",
"value":"Subject Text"
}
]
}
}
I got response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Recipient address required"
}
],
"code": 400,
"message": "Recipient address required"
}
}
Upvotes: 0
Views: 1069
Reputation: 6729
This means that your format in sending email is not valid. Check the documentation for Users.messages and Users.messages: send for the proper format.
{ "id": string, "threadId": string, "labelIds": [ string ], "snippet": string, "historyId": unsigned long, "internalDate": long, "payload": { "partId": string, "mimeType": string, "filename": string, "headers": [ { "name": string, "value": string } ], "body": users.messages.attachments Resource, "parts": [ (MessagePart) ] }, "sizeEstimate": integer, "raw": bytes }
You can also check out the following SO post for more in depth discussion about you error.
Upvotes: 0