1

I am trying to create an org unit in the Google Admin Console, but it seems to ask for two arguments and I cannot find what to put in the second, unless it is to add a user, and then I have no idea how to create the org unit. What I have is this:

function createOrg() {

  var resource = {
    name: "TEST",
    description: "The test",
    parentOrgUnitPath: "/",
    blockInheritance: false
  }

var org = AdminDirectory.Domains.insert(resource, ?????);
}

UPDATE

First I had to follow this link here to get the "Customer" which is really the ID of the admin user I suppose. Then another error came out which was "Missing required field: domainName", So I tried adding that, but again, another error which was "Invalid Value", so I still don't know what is wrong. Now the script is:

function createOrg() {

  var resource = {
    domainName: "TEST",
    name: "TEST",
    description: "The is a test",
    parentOrgUnitPath: "/",
    blockInheritance: false
  }
 var customer = 'USERID';
 var org = AdminDirectory.Domains.insert(resource,customer);
}

UPDATE

As was mentioned below, the only thing that had to be changed was Orgunits instead of Domains:

var org = AdminDirectory.Orgunits.insert(resource,customer);
Jason Jurotich
  • 441
  • 4
  • 24
  • https://developers.google.com/admin-sdk/directory/v1/reference/domains/insert Per Apps Script documentation, the request body is the first arg, then required path parameters (like the id of the gsuite account), then optional parameters (like `fields` specifications for the returned response data). – tehhowch Jul 21 '18 at 15:29
  • The guide on org units may be helpful: https://developers.google.com/admin-sdk/directory/v1/guides/manage-org-units – tehhowch Jul 21 '18 at 16:01
  • Sadly, I already reviewed that, and nothing indicates that you have to have a "domainName" field. – Jason Jurotich Jul 21 '18 at 16:17
  • I notice you're using `AdminDirectory.Domains.insert` - the link says to use [`AdminDirectory.Orgunits.insert`](https://developers.google.com/admin-sdk/directory/v1/reference/orgunits/insert) to create an organizational unit. – tehhowch Jul 21 '18 at 16:36
  • 1
    That worked, please put this as an answer in order to mark this as resolved. – Jason Jurotich Jul 21 '18 at 17:47
  • I'd say that was just a typo. Feel free to work up a better answer with example code and links to relevant property definitions – tehhowch Jul 21 '18 at 18:48

0 Answers0