I'm trying, without any success, to add an alias to a secondary domain in my google apps for work using domain api.
In this article it's written: Domain aliases for secondary domains must be added via the Domains API
Using APIs Explorer I tried this query:
POST https://www.googleapis.com/admin/directory/v1/customer/my_customer/domains?key={YOUR_API_KEY}
{
"domainName": "primarydomain.com",
"domainAliases": [
{
"parentDomainName": "secondarydomain.com",
"domainAliasName": "secondarydomainalias.it",
"verified": false
}
]
}
but I get the following error
> 409 Conflict
>
> - Hide headers -
>
> Cache-Control: private, max-age=0
> Content-Encoding: gzip
> Content-Length: 136
> Content-Type: application/json; charset=UTF-8
> Date: Thu, 18 Feb 2016 16:35:14 GMT
> Expires: Thu, 18 Feb 2016 16:35:14 GMT
> Server: GSE
> Vary: Origin, X-Origin
>
> {
> "error": {
> "errors": [
> {
> "domain": "global",
> "reason": "duplicate",
> "message": "Domain is already set up."
> }
> ],
> "code": 409,
> "message": "Domain is already set up."
> }
> }
Anyone with the same issue found a solution?
Bests
Alder
Edit: I re-read your question and my answer is changed as I see the problem - both your POST endpoint and data are incorrect.
The correct endpoint is
https://www.googleapis.com/admin/directory/v1/customer/<customerId>/domainaliases
and the correct data is
You can try this here on the domain aliases insert page
You will need your domain's "customerId" to make these requests, get it by doing a get on a user in the domain.