The sample shows the PATCH /environments/{{envID}}/users/{{userID}}
operation to update attribute properties using a JSON array in the request body. The operation uses the application/vnd.pingidentity.user.scim.patch+json
custom content type in the request header, and the request body must contain the Operations
property with an array as its value.
The Operations
property specifies the type of update operation in the Operations.op
attribute. Options for this attribute include add
, replace
, and remove
. The Operations.path
attibute specifies the user schema property to modify in the PATCH. The Operations.value
attribute specifies the new value for the modified user schema property.
SCIM PATCH with multi-valued attributes
When you update a multi-valued attribute using application/json
as the Content-Type
HTTP header value, you must update the entire multi-valued attribute. The PATCH action associated with the application/vnd.pingidentity.user.scim.patch+json
is useful for updating targeted elements in a multi-valued attribute. For example, the following multi-valued attribute specifies T-shirt sizes and colors:
{
"tShirt":[
{
"tshirtSize":"XS",
"tshirtColor":"Blue"
},
{
"tshirtSize":"XL",
"tshirtColor":"Red"
}
]
}
The following PATCH request body specifies two operations. The first operation performs a replace
action; it finds all instances of tshirtSize
with a value XS
and replaces the current tshirtColor
attribute with the new color Orange
. For this modification, the Operations.path
uses a SCIM expression to find the XS
T-shirt sizes and update the associated tshirtColor
attribute. The second operation uses an add
action to add a new T-shirt size and color to the multi-valued atttribute.
{
"Operations":[
{
"op":"replace",
"path":"tShirt[tshirtSize eq \\\"XS\\\"].tshirtColor",
"value":"Orange"
},
{
"op":"add",
"path":"tShirt",
"value":[
{
"tshirtSize":"L",
"tshirtColor":"Yellow"
}
]
}
]
}
The multi-valued attribute looks like this after the update:
{
"tShirt":[
{
"tshirtSize":"XS",
"tshirtColor":"Orange"
},
{
"tshirtSize":"XL",
"tshirtColor":"Red"
},
{
"tshirtSize":"L",
"tshirtColor":"Yellow"
}
]
}