microsoftgraph / microsoftgraph/msgraph-beta-sdk-dotnet
Unable to create TrustFrameworkPolicy
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 112
- Forks
- 37
- Avg merge
- 14h 57m
- Merged PRs (30d)
- 3
Description
I'm trying to manage my Azure B2C policies with the graph API using the beta sdk but i'm unable to create a TrustFrameworkPolicy from scratch. Using SDK v4 4.74.0-preview
var policyResult = await graphClient.TrustFramework.Policies.Request().AddAsync(policy);
The above line errors with "The policy being uploaded is not XML or is not correctly formatted: Data at the root level is invalid. Line 1, position 1."
This is weird because there is no XML involved. There's no way to specifiy the TrustFrameworkPolicyContent at this stage.
According to the docs the Content-Type should be set to "application/xml" for a "create" request.
I tried the following :
var policiesRequestBuilder = graphClient.TrustFramework.Policies;
var policiesUrl = policiesRequestBuilder.RequestUrl;
var policiesBuilder = new TrustFrameworkPolicyRequestBuilder(policiesUrl, graphClient);
var policyRequest = policiesBuilder.Request();
policyRequest.ContentType = "application/xml";
var policyResult = await policyRequest.CreateAsync(policy);
var policyContentRequestBuilder = graphClient.TrustFramework.Policies[policyResult.Id];
var policyUrl = policyContentRequestBuilder.AppendSegmentToRequestUrl("$value");
var policyContentBuilder = new TrustFrameworkPolicyContentRequestBuilder(policyUrl, graphClient);
var policyContentResult = await policyContentBuilder.Request().PutAsync(stream);
Still the same error occurs.
Is this a bug or am I using the functionality the wrong way...
UPDATE:
I upgraded to 5.49.0 and i still get the same error.
TrustFrameworkPolicy policy = new()
{
Id ="TEST"
};
var policyResult = await graphClient.TrustFramework.Policies.PostAsync(policy, requestConfiguration =>
{
requestConfiguration.Headers.Add("content-type", "application/xml");
});
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 TrustFramework.Policies create flow using TrustFrameworkPolicyRequestBuilder and the PostAsync example, then inspect the request content type and body against the linked Microsoft Graph API documentation. Confirm whether the SDK can create a policy without XML content and define the expected behavior for the create and $value upload calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100