You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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");
});
The text was updated successfully, but these errors were encountered:
It looks like the metadata used to generate the SDK for this endpoint is incorrect, causing the SDK to build json payloads rather than build an xml payload. Are you able to confirm if you are able to make a successful request on the Graph Explorer?
Using V5 of the SDK, you may have to do something like close to this to convert the xml to json and send it out
TrustFrameworkPolicypolicy=new(){Id="TEST"};varrequestInformation=graphClient.TrustFramework.Policies.ToPostRequestInformation(policy);//convert the json to xmlvarjsonString=awaitnewStreamReader(requestInformation.Content).ReadToEndAsync();varxmlDocument=JsonConvert.DeserializeXmlNode(jsonString,"TrustFrameworkPolicy");varoutputStream=newMemoryStream(Encoding.UTF8.GetBytes(xmlDocument.OuterXml));//set the xml stream contentrequestInformation.SetStreamContent(outputStream);requestInformation.Headers.Add("Content-Type","application/xml");varerrorMapping=newDictionary<string,ParsableFactory<IParsable>>{{"4XX",ODataError.CreateFromDiscriminatorValue},{"5XX",ODataError.CreateFromDiscriminatorValue},};awaitgraphClient.RequestAdapter.SendNoContentAsync(requestInformation,errorMapping);
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 :
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.
The text was updated successfully, but these errors were encountered: