Chilkat Online Tools

unicodeCpp / Atlassian Confluence Cloud / Set retention period

Back to Collection Items

#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>
#include <CkHttpResponseW.h>

void ChilkatSample(void)
    {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttpW http;
    bool success;

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "number": "<integer>",
    //   "units": "<string>"
    // }

    CkJsonObjectW json;
    json.UpdateString(L"number",L"<integer>");
    json.UpdateString(L"units",L"<string>");

    http.SetRequestHeader(L"Content-Type",L"application/json");

    CkStringBuilderW sbRequestBody;
    json.EmitSb(sbRequestBody);

    CkHttpResponseW *resp = http.PTextSb(L"PUT",L"https://your-domain.atlassian.net/wiki/rest/api/audit/retention",sbRequestBody,L"utf-8",L"application/json",false,false);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    CkStringBuilderW sbResponseBody;
    resp->GetBodySb(sbResponseBody);

    CkJsonObjectW jResp;
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",jResp.emit());

    int respStatusCode = resp->get_StatusCode();
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",resp->header());
        wprintf(L"Failed.\n");
        delete resp;
        return;
    }

    delete resp;

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "number": "<integer>",
    //   "units": "<string>"
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    const wchar_t *v_number = jResp.stringOf(L"number");
    const wchar_t *units = jResp.stringOf(L"units");
    }

Curl Command

curl -X PUT
	-H "Content-Type: application/json"
	-d '{
    "number": "<integer>",
    "units": "<string>"
}'
https://your-domain.atlassian.net/wiki/rest/api/audit/retention

Postman Collection Item JSON

{
  "name": "Set retention period",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"number\": \"<integer>\",\n    \"units\": \"<string>\"\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/api/audit/retention",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "audit",
        "retention"
      ]
    },
    "description": "Sets the retention period for records in the audit log. The retention period\ncan be set to a maximum of 20 years.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\n'Confluence Administrator' global permission."
  },
  "response": [
    {
      "name": "Returned if the retention period is updated.",
      "originalRequest": {
        "method": "PUT",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"number\": \"<integer>\",\n    \"units\": \"<string>\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/audit/retention",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "audit",
            "retention"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"number\": \"<integer>\",\n \"units\": \"<string>\"\n}"
    },
    {
      "name": "Returned if the calling user does not have permission to view the audit\nlog.",
      "originalRequest": {
        "method": "PUT",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"number\": \"<integer>\",\n    \"units\": \"<string>\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/audit/retention",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "audit",
            "retention"
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}