Resource 'XXXXXXXX-XXXX-XXXX-XXX-XXXXXXXXXXXX' does not exist or one of its queried reference-property objects are not present

2021-08-17T00:18:10.053+00:00

I had created a clientId, tenantId of my app, too I had created a clientSecret, the client secret has all right (read, write, etc). My question is when I create a group I get this Error in java:

Error message: Resource 'XXXXXXXX-XXXX-XXXX-XXX-XXXXXXXXXXXX' does not exist or one of its queried reference-property objects are not present.

I think , what I need associate my user id (XXXXXXXX-XXXX-XXXX-XXX-XXXXXXXXXXXX) with the client secret or tenantId (the tenant id of my app). Someone would say me how to fix that?, thanks.

    final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder().clientId("bbbb").clientSecret("yyy").tenantId("zzz").build();
    List scope = new ArrayList<>();
    scope.add("https://graph.microsoft.com/.default");
    final TokenCredentialAuthProvider tokenCredentialAuthProvider = new TokenCredentialAuthProvider( scope, clientSecretCredential);

    final GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider(tokenCredentialAuthProvider).buildClient();
    GroupCollectionPage groupCollectionPage = graphClient.groups().buildRequest().get();
    Group group = new Group();
    group.displayName = "Group Test 2";
    group.mailEnabled = false;
    group.mailNickname = "grouptest2";
    group.securityEnabled = true;
    final JsonArray array = new JsonArray();
    array.add("https://graph.microsoft.com/v1.0/users/" + "XXXXXXXX-XXXX-XXXX-XXX-XXXXXXXXXXXX");
    group.additionalDataManager().put("owners@odata.bind", array);
    final Group created = graphClient.groups().buildRequest().post(group);
    String idGroup = graphClient.groups().buildRequest().post(group).id;
    log.info(">>idGroup"+idGroup);        
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,592 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 36,896 Reputation points
    2021-08-17T05:55:25.807+00:00

    Try this:

     GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
    
     Group group = new Group();
     group.description = "Group with designated owner and members";
     group.displayName = "Operations group";
     LinkedList<String> groupTypesList = new LinkedList<String>();
     group.groupTypes = groupTypesList;
     group.mailEnabled = false;
     group.mailNickname = "operations2019";
     group.securityEnabled = true;
     group.additionalDataManager().put("owners@odata.bind", new JsonPrimitive("[  \"https://graph.microsoft.com/v1.0/users/26be1845-4119-4801-a799-aea79d09f1a2\"]"));
     group.additionalDataManager().put("members@odata.bind", new JsonPrimitive("[  \"https://graph.microsoft.com/v1.0/users/ff7cb387-6688-423c-8188-3da9532a73cc\",  \"https://graph.microsoft.com/v1.0/users/69456242-0067-49d3-ba96-9de6f2728e14\"]"));
    
     graphClient.groups()
         .buildRequest()
         .post(group);