microsoftgraph / microsoftgraph/msgraph-beta-sdk-dotnet
Unable to patch TrustFrameworkPolicy
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 112
- Forks
- 37
- Avg merge
- 14h 57m
- Merged PRs (30d)
- 3
Description
Describe the bug
I am trying to write an automated system for adding and patching TrustFramework Policies using Microsoft.Identity.Web.GraphServiceClientBeta version 3.0.1 which is using Microsoft.Graph.Beta 5.78.0-preview.
I have successfully added a policy from the code provided by: Github msgraph-beta-sdk-dotnet issue 734 but I am unable to patch as it throws the following error:
No HTTP resource was found that matches the request URI 'https://cpim.windows.net/graph/trustFramework/policies('B2C_1A_TEST_01')'.","messageDetail":"No action was found on the controller 'trustframework' that matches the request.
Expected behavior
To patch a B2C Policy using the SDK. From looking at the api it indicates it should be a Put and not a Patch but there is no appropriate RequestInformation method on the graphServiceClient.TrustFramework.Policies[policyId] object.
How to reproduce
Run the following code:
Where:
- data: is a BinaryData object of the xml policy file.
- graphServiceClient: is a Beta.GraphServiceClient.
- policyId: is 'B2C_1A_TEST_01'
TrustFrameworkPolicyCollectionResponse? response = await graphServiceClient.TrustFramework.Policies.GetAsync();
TrustFrameworkPolicy? existingPolicy = response?.Value?.Where(x => x.Id == policyId).FirstOrDefault();
if (existingPolicy != null) {
RequestInformation requestInformation = graphServiceClient.TrustFramework.Policies[policyId].ToPatchRequestInformation(existingPolicy);
requestInformation.SetStreamContent(data.ToStream(), "application/xml");
requestInformation.Headers.Add("Content-Type", "application/xml");
Dictionary<string, ParsableFactory<IParsable>> errorMapping = new()
{
{"4XX", ODataError.CreateFromDiscriminatorValue},
{"5XX", ODataError.CreateFromDiscriminatorValue},
};
}
await graphServiceClient.RequestAdapter.SendNoContentAsync(requestInformation, errorMapping, cancellationToken);
SDK Version
5.78.0-preview
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_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the request through graphServiceClient.TrustFramework.Policies[policyId] and inspect ToPatchRequestInformation alongside the TrustFramework Policies API operation. Verify whether the SDK should issue PUT or PATCH and confirm the resulting URI and method against the reported cpim.windows.net error. Done means the SDK request reaches the policy endpoint successfully and the reproduction completes without the controller or resource error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100