Reputation: 41
I am trying to send emails with the Gmail API. I am trying to use Postman to test my requests and get the proper code to use in my web application, but I keep getting this error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Recipient address required"
}
],
"code": 400,
"message": "Recipient address required"
}
}
I'm using the following link to make a POST request:
https://www.googleapis.com/upload/gmail/v1/users/me/messages/send
In my header, I have the following:
Authorization: Bearer ya29.xxxxxxxxx
Content-Type: message/rfc822
In my request body:
{
"raw" : "RnJvbTogQWxleCBCdWhzZSA8YWxleGJ1aHNlMUBnbWFpbC5jb20-IApUbzogQWxleCBCdWhzZSA8a29vX29saW9AaG90bWFpbC5jb20-IApTdWJqZWN0OiBTYXlpbmcgSGVsbG8geW8KRGF0ZTogRnJpLCAyMSBOb3YgMTk5NyAwOTo1NTowNiAtMDYwMApDb250ZW50LVR5cGU6IHRleHQvaHRtbDsgY2hhcnNldD11dGYtOA=="
}
I have tested the request with through the API testing sidebar on Google's own documentation:
https://developers.google.com/gmail/api/v1/reference/users/messages/send
but I seem to not be having any luck with using it in Postman. I'm using Postman and not the javascript that Google provides because I want to get the proper formatted code for making an AJAX call. I was wondering if anyone has worked with Postman and the Gmail API that may be able to help?
Upvotes: 3
Views: 2724
Reputation: 482
If you want more details please refer below link:
400 error. Recipient address required. JavaScript
Upvotes: 0
Reputation: 11
Host: www.googleapis.com
Content-Type: message/rfc822
Authorization: Bearer MY_TOKEN
Cache-Control: no-cache
Postman-Token: 3b313d0c-e678-49cd-b977-017b6380a25f
{
"raw": "ZnJvbTpteUBnbWFpbC5jb20KdG86c29tZW9uZUByb2JvbXEuaW8KY2M6eW91QGdtYWlsLmNvbQpzdWJqZWN0OlRlc3QgRnJvbSBQb3N0bWFuCk1lc3NhZ2UtSWQ6IGNoZWNraW5nIGluIHBvc3RtYW4KSGVsbG8gRnJvbSBQb3N0bWFuIGluc2h1"
,
"id": "me" ,
payload": {
"filename": "Filename",
"mimeType": "message/rfc822",
"headers": [
{
"name": "to",
"value": "me"
},
],
"body":
{
"attachmentId": "/home/inshu/Desktop/signup.txt",
"data": "",
"size": 1524
}
Upvotes: 0
Reputation: 41
Figured out where I was going wrong. I changed content-type to:
Content-Type: application/JSON
And I changed the request link to:
https://content.googleapis.com/gmail/v1/users/me/messages/send
And that fixed my issue.
Upvotes: 1