简体   繁体   中英

Create users alias in Google API (using c#)

This is error i am getting when i am creating alias in google admin directory for a email address.

Google.Apis.Requests.RequestError
Entity already exists. [409]
Errors [
Message[Entity already exists.] Location[ - ] Reason[duplicate] Domain[global]
]

This is my Code :

I want to create alias for email id : test@test.com

added this id to above : aliasemailid@test.com ===> test@test.com

var aliasesreq = service.Users.Aliases.Insert(new Google.Apis.Admin.Directory.directory_v1.Data.Alias 
                     {
                      AliasValue = "aliasemailid@test.com",
                   }, "test@test.com");

How to do ? Kindly Help

I don't have an admin account so I cant test this. But from checking the documentation on what a Users.aliases looks like I think its probably going to be something like this.

 string userKey = "test@test.com";
 var body = new Google.Apis.Admin.Directory.directory_v1.Data.Alias { PrimaryEmail = userKey, AliasValue = "aliasemailid@test.com" };
 service.Users.Aliases.Insert(body, userKey).Execute();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM