Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkStringBuilderW sbRequestBody;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "organizationId": "{{organization_id}}",
// "userId": "{{user_id}}",
// "roleGroupId": "{{rolegroup_Id}}"
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"organizationId",L"{{organization_id}}");
CkJsonObjectW_UpdateString(json,L"userId",L"{{user_id}}");
CkJsonObjectW_UpdateString(json,L"roleGroupId",L"{{rolegroup_Id}}");
// Adds the "Authorization: Bearer {{token}}" header.
CkHttpW_putAuthToken(http,L"{{token}}");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
resp = CkHttpW_PTextSb(http,L"DELETE",L"https://domain.com/accounts/api/organizations/{{organization_id}}/rolegroups/{{rolegroup_Id}}/users/{{user_id}}",sbRequestBody,L"utf-8",L"application/json",FALSE,FALSE);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
}
Curl Command
curl -X DELETE
-H "Authorization: Bearer {{token}}"
-d '{
"organizationId":"{{organization_id}}",
"userId":"{{user_id}}",
"roleGroupId":"{{rolegroup_Id}}"
}'
https://domain.com/accounts/api/organizations/{{organization_id}}/rolegroups/{{rolegroup_Id}}/users/{{user_id}}
Postman Collection Item JSON
{
"name": "Delete user from rolegroup",
"request": {
"method": "DELETE",
"header": [
{
"key": "Authorization",
"value": "Bearer {{token}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"organizationId\":\"{{organization_id}}\",\r\n \"userId\":\"{{user_id}}\",\r\n \"roleGroupId\":\"{{rolegroup_Id}}\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}/accounts/api/organizations/{{organization_id}}/rolegroups/{{rolegroup_Id}}/users/{{user_id}}",
"host": [
"{{url}}"
],
"path": [
"accounts",
"api",
"organizations",
"{{organization_id}}",
"rolegroups",
"{{rolegroup_Id}}",
"users",
"{{user_id}}"
]
}
},
"response": [
]
}