James
James

Reputation: 31

GMail API SendAs GET not showing displayname without alias

Can't seem to find questions that address this directly but does anyone know why the endpoint https://developers.google.com/gmail/api/reference/rest/v1/users.settings.sendAs/list does not list the default displayName when an alias is NOT set up?

{
  "sendAs": [
    {
      "sendAsEmail": "[email protected]",
      "displayName": "",
      "replyToAddress": "",
      "signature": "",
      "isPrimary": true,
      "isDefault": true
    }
  ]
}

From my testing, it looks like if you create an alternate display name using the steps listed here https://support.google.com/mail/answer/8158?hl=en, the response will show up as

{
  "sendAs": [
    {
      "sendAsEmail": "[email protected]",
      "displayName": "New Alternate Name",
      "replyToAddress": "",
      "signature": "",
      "isPrimary": true,
      "isDefault": true
    }
  ]
}

And if you add another email address to alias, you get

{
  "sendAs": [
    {
      "sendAsEmail": "[email protected]",
      "displayName": "New Alternate Name",
      "replyToAddress": "",
      "signature": "",
      "isPrimary": true,
      "isDefault": true
    },
    {
      "sendAsEmail": "[email protected]",
      "displayName": "Foo 2 Name",
      "replyToAddress": "",
      "signature": "",
      "treatAsAlias": true,
      "verificationStatus": "accepted",
      "isDefault": false
    }
  ]
}

But if you revert your main email's displayname to the original default, you get

{
  "sendAs": [
    {
      "sendAsEmail": "[email protected]",
      "displayName": "",
      "replyToAddress": "",
      "signature": "",
      "isPrimary": true,
      "isDefault": true
    },
    {
      "sendAsEmail": "[email protected]",
      "displayName": "Foo 2 Name",
      "replyToAddress": "",
      "signature": "",
      "treatAsAlias": true,
      "verificationStatus": "accepted",
      "isDefault": false
    }
  ]
}

Was running into issues locally with Java but testing it on the "Try this API" features creates the same results so I am thinking this is WAD and I might need to be using something else.

Upvotes: 2

Views: 765

Answers (1)

fullfine
fullfine

Reputation: 1461

The method list of the resource user.settings.sendAs returns an SendAs object, which contains a field called displayName and it is describe as:

A name that appears in the "From:" header for mail sent using this alias.

It means that if you aren't using an alias, it will be empty. If you want to retrieve the full name of your account you can use the Admin API, with the method get of the resource users, but it is restricted to admin users of your domain.

Reference:

Upvotes: 1

Related Questions