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.
// {
// "name": "test32",
// "downloadable": true
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"name",L"test32");
CkJsonObjectW_UpdateBool(json,L"downloadable",TRUE);
CkHttpW_SetRequestHeader(http,L"X-ANYPNT-ENV-ID",L"{{environment_id}}");
// Adds the "Authorization: Bearer {{token}}" header.
CkHttpW_putAuthToken(http,L"{{token}}");
CkHttpW_SetRequestHeader(http,L"X-ANYPNT-ORG-ID",L"{{organization_id}}");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
resp = CkHttpW_PTextSb(http,L"PATCH",L"https://domain.com/secrets-manager/api/v1/organizations/{{organization_id}}/environments/{{environment_id}}/secretGroups/{{secretgroup_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 PATCH
-H "Authorization: Bearer {{token}}"
-H "X-ANYPNT-ORG-ID: {{organization_id}}"
-H "X-ANYPNT-ENV-ID: {{environment_id}}"
-d '{
"name":"test32",
"downloadable":true
}'
https://domain.com/secrets-manager/api/v1/organizations/{{organization_id}}/environments/{{environment_id}}/secretGroups/{{secretgroup_Id}}
Postman Collection Item JSON
{
"name": "Rename secretgroup",
"request": {
"method": "PATCH",
"header": [
{
"key": "Authorization",
"value": "Bearer {{token}}",
"type": "text"
},
{
"key": "X-ANYPNT-ORG-ID",
"value": "{{organization_id}}",
"type": "text"
},
{
"key": "X-ANYPNT-ENV-ID",
"value": "{{environment_id}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"name\":\"test32\",\r\n \"downloadable\":true\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}/secrets-manager/api/v1/organizations/{{organization_id}}/environments/{{environment_id}}/secretGroups/{{secretgroup_Id}}",
"host": [
"{{url}}"
],
"path": [
"secrets-manager",
"api",
"v1",
"organizations",
"{{organization_id}}",
"environments",
"{{environment_id}}",
"secretGroups",
"{{secretgroup_Id}}"
]
}
},
"response": [
]
}