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

[email protected] Field Missing Error in Microsoft Graph API /chats POST Request #2577

Closed
julianmaurice opened this issue Jul 10, 2024 · 4 comments
Labels

Comments

@julianmaurice
Copy link

julianmaurice commented Jul 10, 2024

Describe the bug

I am encountering an issue with the Microsoft Graph API when attempting to create a new chat using the /chats POST request. The request fails with the following error message:

Microsoft.Graph.Models.ODataErrors.ODataError: 'user@odata.bind' field is missing in the request.

Despite ensuring that the [email protected] field is correctly formatted and included in the request, the API still returns this error. This problem has only recently started occurring, and the same code was functioning correctly before.

Expected behavior

The chat should be created successfully, with the members specified in the Members list being correctly added to the chat.

How to reproduce

Steps to reproduce the behavior:

  1. Use the Microsoft Graph SDK for C# to create a new chat.
  2. Format the request as follows:
var chatRequestBody = new Chat
        {
            ChatType = ChatType.OneOnOne,
            Members = new List<ConversationMember>
            {
                new AadUserConversationMember
                {
                    Roles = new List<string>
                    {
                        "owner",
                    },
                    AdditionalData = new Dictionary<string, object>
                    {
                        {
                            "[email protected]" , $"https://graph.microsoft.com/v1.0/users('{Environment.GetEnvironmentVariable("SupportAccount")}')"
                        },
                    },
                },
                new AadUserConversationMember
                {
                    Roles = new List<string>
                    {
                        "owner",
                    },
                    AdditionalData = new Dictionary<string, object>
                    {
                        {
                            "[email protected]" , $"https://graph.microsoft.com/v1.0/users('{userId}')"
                        },
                    },
                },
            },
        };
        
        
        var chat = await _graphServiceClient
            .Chats
            .PostAsync(chatRequestBody);
  1. Execute the request and observe the error.

SDK Version

5.56.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_
@julianmaurice julianmaurice added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jul 10, 2024
@andrueastman
Copy link
Member

Thanks for raising this @julianmaurice

Any chance you can confirm again the version of the SDK you are using? The issue mentions 5.56.0 however Request() methods were removed in 5.x.x versions of the SDK...

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Jul 10, 2024
@julianmaurice
Copy link
Author

Ah, sorry for the confusion. I updated the post to clarify that the issue is with the request body. Specifically, I am including [email protected] in the AdditionalData, but the API responds with the error.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Jul 10, 2024
@andrueastman
Copy link
Member

Thanks for confirming

Are you able to get the json response payload and use it to make a similar request on the Graph Explorer?
Do you still get the same error?

var jsonString = KiotaJsonSerializer.SerializeAsString(chatRequestBody);

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Jul 11, 2024
@julianmaurice
Copy link
Author

Ah, very nice! This snippet allowed me to see that the request sent by the client was correctly formatted. I realized that the mistake was in my code. Thank you for your help!

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants