Início / Optitravel / Helpers / ScimHelper
sendResponse(array $data, int $code = 201)
This method sends a formatted SCIM-compliant JSON response with the appropriate HTTP status code and headers.
Parameters
-
$data – (array) Required. The data to be returned in the HTTP response.
-
$code – (int) Optional. The HTTP status code to send (default: 201).
Behavior
This function:
-
Applies array_prepare($data, 'UTF-8') to ensure proper UTF-8 encoding.
-
Sets the HTTP response code to the given $code.
-
Sends the Content-Type: application/scim+json header.
-
Outputs the $data array as JSON, using:
-
JSON_UNESCAPED_UNICODE (to preserve non-ASCII characters),
-
JSON_PRETTY_PRINT (for human-readable formatting).
Example
The output will be something like this:
{
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:Group"
],
"id": "32",
"displayName": "FINANCE",
"members": [
{
"value": "7665",
"display": "Api Rest Teste",
"ref": "https://dsv-rest.optigest.net:10300/scim/v2/Users/7665",
"type": "User"
},
{
"value": "2987",
"display": "teste",
"ref": "https://dsv-rest.optigest.net:10300/scim/v2/Users/2987",
"type": "User"
}
],
"meta": {
"resourceType": "Group",
"created": "2025-05-14 09:23:12",
"lastModified": "2025-05-14 09:23:12",
"location": "dsv-rest.optigest.net:10300/scim/v2/Groups"
}
}
With HTTP headers:
HTTP/1.1 201 Created
Content-Type: application/scim+json
↑ (Última atualização: 14/05/2025)