Directory API moving an organization unit using google api for java to another organization unit

瘦欲@ 提交于 2020-01-22 03:39:32

问题


I am testing moving an organization unit from under one parent to another. Right now i have a following OUs:

YourDomain.com
-Middle Schools
--Grade07
-Elementary Schools
--Grade01
--Garde02

I want to move Grade 07 to Elementary School OU for example. Here is my code snippet:

List<String> list = new ArrayList<String>();
    list.add("Middle Schools");
    list.add("Grade 07");
    OrgUnit ou = sDirectory.orgunits().get("my_customer", list).execute();
    ou.setParentOrgUnitPath("/Elementary Schools");
    ou.setOrgUnitPath("/Elementary Schools/Grade 07");
    list.clear();
    list.add("Elementary Schools");
    list.add("Grade 07");
    sDirectory.orgunits().update("my_customer", list, ou).execute(); 

I keep getting the following error:

404 Not Found
{
  "code" : 404,
  "errors" : [ {
    "domain" : "global",
    "message" : "Org unit not found",
    "reason" : "notFound"
  } ],
  "message" : "Org unit not found"
}

What did i miss?


回答1:


I tried this and it worked. I realize you only need to update the parentOrgUnitPath. So the above code looks ike this:

List<String> list = new ArrayList<String>();
    list.add("Middle Schools");
    list.add("Grade 07");
    OrgUnit ou = sDirectory.orgunits().get("my_customer", list).execute();
    ou.setParentOrgUnitPath("/Elementary Schools");
    sDirectory.orgunits().update("my_customer", list, ou).execute(); 


来源:https://stackoverflow.com/questions/22000653/directory-api-moving-an-organization-unit-using-google-api-for-java-to-another-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!