Reputation: 51
I am calling a REST API from custom policy. I am sending JSON data in the request body, and a sample JSON data is"
I am little bit confused how to send the below JSON (address and contacts) as input claim from my custom policy.
{
"firstName": "sampleuser",
"lastName": "qa",
"addresses": [
{
"countryCode": "IN"
}
],
"contacts": {
"email": {
"address": "[email protected]"
}
}
}
Upvotes: 1
Views: 1371
Reputation: 11315
B2C can only build a JSON from its own claim type primitives. Which are int, boolean, datetime, string, stringCollection.
For example, by outputting these claims in a REST API technical profile:
<OutputClaim ClaimTypeReferenceId="firstName" />
<OutputClaim ClaimTypeReferenceId="lastName" />
<OutputClaim ClaimTypeReferenceId="addresses" />
With these definitions:
<ClaimType Id="firstName">
<DisplayName>firstName</DisplayName>
<DataType>string</DataType>
</ClaimType>
<ClaimType Id="lastName">
<DisplayName>lastName</DisplayName>
<DataType>string</DataType>
</ClaimType>
<ClaimType Id="addresses">
<DisplayName>addresses</DisplayName>
<DataType>stringCollection</DataType>
</ClaimType>
The resulting JSON payload to the API will be
{
"firstName": "sampleuser",
"lastName": "qa",
"addresses": "X, Y, Z",
}
Since we do not model the json object themselves, we cannot build a JSON payload like:
"addresses": [
{
"countryCode": "IN"
}
],
"contacts": {
"email": {
"address": "[email protected]"
}
}
Depending on how you are obtaining this information from a user or backend system, this JSON claims transformation might be helpful in splitting the data into string/stringCollections to send the data to an API.
https://learn.microsoft.com/en-us/azure/active-directory-b2c/json-transformations
https://learn.microsoft.com/en-us/azure/active-directory-b2c/stringcollection-transformations
Upvotes: 1