c# - Google Dotnet API - Admin SDK Groups - Getting Bad Request Error -
just trying out peruse google dotnet api admin sdk work.
i having errors when seek retrieve listing of groups. still confused @ documentation (which methods or functions utilize etc.).
the codes have right now:
using system; using system.io; using system.threading; using google.apis.auth.oauth2; using google.apis.services; using google.apis.util.store; using google.apis.admin.directory.directory_v1; using google.apis.admin.directory.directory_v1.data; namespace googleconsoleapp { class programme { static void main(string[] args) { usercredential credential; using (var stream = new filestream("client_secrets.json", filemode.open, fileaccess.read)) { credential = googlewebauthorizationbroker.authorizeasync( googleclientsecrets.load(stream).secrets, new[] { directoryservice.scope.admindirectorygroup, directoryservice.scope.admindirectorygroupreadonly }, "user", cancellationtoken.none, new filedatastore("tasks.auth.store")).result; } var dirsvc = new directoryservice(new baseclientservice.initializer() { httpclientinitializer = credential, applicationname = "groups api sample", }); groups mygroups = dirsvc.groups.list().execute();
pretty much errors out saying:
unhandled exception: google.googleapiexception: google.apis.requests.requesterror bad request [400] errors: [message [bad request] location [ - ] reason[badrequest] domain[global]]
i've enabled necessary apis in developer's console.
any help regarding appreciated.
update: tried method (as per documentation):
google.apis.admin.directory.directory_v1.groupsresource.listrequest lreq = new groupsresource.listrequest(dirsvc); groups grp2 = lreq.execute();
but still same error.
you need explicitly set domain of request. error in assuming search global domain if leave domain blank other types of requests do. in case instead tries search groups of customer, blank. note in api spec.
when retrieving:
all groups sub-domain — utilize domain argument domain's name. all groups business relationship — utilize client argument either my_customer or account's customerid value. business relationship administrator, utilize string my_customer represent account's customerid. if reseller accessing resold customer's account, utilize resold account's customerid. customerid value utilize account's primary domain name in retrieve users in domain operation's request. resulting response has customerid value. using both domain , client arguments — api returns groups domain. not using domain , client arguments — api returns groups business relationship associated my_customer. business relationship customerid of administrator making api request.example works:
groupsresource.listrequest grouprequest = _service.groups.list(); grouprequest.domain = "yourdomain"; groups domaingroups = grouprequest.execute();
example not work , throw exact same error:
groupsresource.listrequest grouprequest = _service.groups.list(); groups domaingroups = grouprequest.execute();
c# google-api-dotnet-client
No comments:
Post a Comment