Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidRequest: Missing header Client-Request-Id. Header Client-Request-Id is not a guid #2164

Open
praducg opened this issue Sep 21, 2024 · 0 comments
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned

Comments

@praducg
Copy link

praducg commented Sep 21, 2024

Graph API End point:
POST https://graph.microsoft.com/v1.0/drive/items/{item-id}/workbook/comments

Request Body:

{
  "content": "This is a sample text"
}

I am passing GUID in the Client-Request-Id but still the issue remains same.

When posting comments to a word document using graph Client getting
Error message: {"code":"InvalidRequest","message":"Missing header Client-Request-Id. Header Client-Request-Id is not a guid.","innerError":{"request-id":"00000000-0000-0000-0000-000000000000","date":"2024-09-20T17:03:58.6112675-07:00"}}

I tried using GraphExplorer,JavaCode(Refer Below),JavaScriptClient and everywhere the issue remains same.


import java.util.UUID;

import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.io.entity.StringEntity;

public class AddComment {
    public static void main(String[] args) {
        try {
            String url = "https://graph.microsoft.com/v1.0/sites/" + "my-site-id" + "/drives/" + "my-drive-id" + "/items/" + "item-id" + "/workbook/comments";

            String clientRequestId = UUID.randomUUID().toString(); // Generate a new GUID
 
            CloseableHttpClient client = HttpClients.createDefault();
            HttpPost post = new HttpPost(url);

            post.setHeader("Authorization", "Bearer access-token");
            post.setHeader("client-Request-Id", clientRequestId);
            post.setHeader("Content-Type", "application/json");
            String json = "{\"content\": \"MS Document Comment\"}";
            StringEntity entity = new StringEntity(json);
            post.setEntity(entity);

            CloseableHttpResponse response = client.execute(post);
            String responseBody = EntityUtils.toString(response.getEntity());
            System.out.println(response.getCode());
            System.out.println(responseBody);

            client.close();
            // Handle the response...

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

@praducg praducg added the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned
Projects
None yet
Development

No branches or pull requests

1 participant