microsoftgraph / microsoftgraph/msgraph-beta-sdk-dotnet

Create new ApprovalItem - error response : malformed or incorrect

Open
#943 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Needs investigation type:bug
Dominant language
C#
Stars
112
Forks
37
Avg merge
14h 57m
Merged PRs (30d)
3

Description

Describe the bug

I submit a new approvalitem. The api response that the message are malformed or incorrect.

The body of the request looks like following json. The problem is that there is an additional odata type information.

{
    "allowEmailNotification": true,
    "approvalType": "basic",
    "approvers": [
        {
            "@odata.type": "#microsoft.graph.approvalIdentitySet",
            "user": {
                "displayName": "Alex Wilber",
                "id": "9a033c37-4b75-4a89-87f6-8cd7f5b66026"
            }
        }
    ],
    "description": "Details",
    "displayName": "Title of approval 22"
}
Expected behavior

Ignore the odata type by converting the object to a json string
"@odata.type": "#microsoft.graph.approvalIdentitySet",

How to reproduce
var requestBody = new ApprovalItem
  {
      DisplayName = "Title of approval 22",
      Description = "Details",
      ApprovalType = ApprovalItemType.Basic,
      AllowEmailNotification = true,
      AllowCancel = true,                        
      Approvers = new List<ApprovalIdentitySet>
      {
          new ()
          {
              User = new Identity
              {
                  Id = "9a033c37-4b75-4a89-87f6-8cd7f5b66026",
                  DisplayName= "Alex Wilber"
              },
          }
      }
  };
  var result = await graphBetaClient.Solutions.Approval.ApprovalItems.PostAsync(requestBody)
SDK Version

5.86.0

Latest version known to work for scenario above?

No response

Known Workarounds
Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ApprovalItem request construction and the Solutions.Approval.ApprovalItems.PostAsync entry point, then trace how Approvers is serialized into the request body. Reproduce the issue with the supplied example and verify that the generated JSON no longer includes the unwanted @odata.type field.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.