How can I add O365 contacts using batch API? (Java)

Yoppi 0 Reputation points
In the Microsoft Graph SDK for Java,
I'm trying to write an application that uses the batch API to add contacts.

I referred to the URL below, but I don't know how to implement it when replacing it with the contact API.

Is there a java source code sample for adding contacts using batch api?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,486 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. TH-4749-MSFT 3,290 Reputation points

    Hello Yoppi,

    Thanks for reaching out. You can find an example of creating a contact using Graph Java SDK below.

    For queries related to Graph SDK please refer to the respective Graph SDK Github Forum.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


  2. Yoppi 0 Reputation points

    With reference to batch sample code

    I wrote a batch code that registers the name in the contact form.

    The status after execution is 200, but it is not added to correspondence.

    Please let me know if anyone knows what is wrong.
    Thank you.

    GraphServiceClient oGraphClient = oClientCredPrv.getGraphClient();
    BatchRequestContent oBatchRequestContent = new BatchRequestContent();
    List<QueryOption> oContactList = Arrays.asList(new QueryOption("givenName", "John "),
    new QueryOption("surname", "Smith"));
    IHttpRequest oHttpRequest = oGraphClient.users(p_Upn).contacts().buildRequest(oContactList);
    String oRequestStepId = oBatchRequestContent.addBatchRequestStep(oHttpRequest);
    BatchResponseContent batchResponseContent = Objects
    BatchResponseStep<JsonElement> oContactsResponse = Objects
    System.out.println("result:" + oContactsResponse.status);
    0 comments No comments