I have the following Org Units hierarchy:
..
../Unit1
..../SubUnit
../Unit2
I'm trying to move SubUnit from Unit1 to Unit2 with code like this:
List<String> list = new ArrayList<String>();
list.add("Unit1");
list.add("SubUnit");
OrgUnit orgUnit = directoryService.orgunits().get("my_customer", list).execute();
orgUnit.setParentOrgUnitPath("/Unit2");
directoryService.orgunits().update("my_customer", list, orgUnit ).execute();
but it always fails with:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
{
"code" : 404,
"errors" : [ {
"domain" : "global",
"message" : "Parent Org unit not found",
"reason" : "notFound"
} ],
"message" : "Parent Org unit not found"
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1056)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
The error message is quite clear, but the ParentOrgUnit exists at the moment of the call and its path is provided correctly. I tried many times with different units with same result using:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-admin-directory</artifactId>
<version>directory_v1-rev53-1.20.0</version>
</dependency>
Any help?
The only question I've found about but it doesn't help: Directory API moving an organization unit using google api for java to another organization unit