Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
#include <C_CkStringBuilder.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkJsonObject queryParams;
HCkHttpResponse resp;
HCkStringBuilder sbResponseBody;
HCkJsonObject jResp;
int respStatusCode;
const char *value;
const char *Attachment;
const char *Comment;
const char *Page;
int Start;
int Limit;
int Size;
int commentStart;
int commentLimit;
int commentSize;
int pageStart;
int pageLimit;
int pageSize;
int i;
int count_i;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
queryParams = CkJsonObject_Create();
CkJsonObject_UpdateString(queryParams,"expand","<string>");
CkJsonObject_UpdateString(queryParams,"expand","<string>");
// Adds the "Authorization: Bearer <access_token>" header.
CkHttp_putAuthToken(http,"<access_token>");
resp = CkHttp_QuickRequestParams(http,"GET","https://your-domain.atlassian.net/wiki/rest/api/content/:id/descendant",queryParams);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(queryParams);
return;
}
sbResponseBody = CkStringBuilder_Create();
CkHttpResponse_GetBodySb(resp,sbResponseBody);
jResp = CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,FALSE);
printf("Response Body:\n");
printf("%s\n",CkJsonObject_emit(jResp));
respStatusCode = CkHttpResponse_getStatusCode(resp);
printf("Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
printf("Response Header:\n");
printf("%s\n",CkHttpResponse_header(resp));
printf("Failed.\n");
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(queryParams);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
return;
}
CkHttpResponse_Dispose(resp);
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "_expandable": {
// "attachment": "in ut",
// "comment": "dolor",
// "page": "eu exercitation"
// },
// "_links": {},
// "attachment": {
// "results": [
// {
// "value": "<Circular reference to #/components/schemas/Content detected>"
// },
// {
// "value": "<Circular reference to #/components/schemas/Content detected>"
// }
// ],
// "start": -75729038,
// "limit": 34726306,
// "size": 18934279,
// "_links": {}
// },
// "comment": {
// "results": [
// {
// "value": "<Circular reference to #/components/schemas/Content detected>"
// },
// {
// "value": "<Circular reference to #/components/schemas/Content detected>"
// }
// ],
// "start": 37994470,
// "limit": 2587712,
// "size": -24049554,
// "_links": {}
// },
// "page": {
// "results": [
// {
// "value": "<Circular reference to #/components/schemas/Content detected>"
// },
// {
// "value": "<Circular reference to #/components/schemas/Content detected>"
// }
// ],
// "start": 66843073,
// "limit": 57682154,
// "size": -4004438,
// "_links": {}
// }
// }
// 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.
Attachment = CkJsonObject_stringOf(jResp,"_expandable.attachment");
Comment = CkJsonObject_stringOf(jResp,"_expandable.comment");
Page = CkJsonObject_stringOf(jResp,"_expandable.page");
Start = CkJsonObject_IntOf(jResp,"attachment.start");
Limit = CkJsonObject_IntOf(jResp,"attachment.limit");
Size = CkJsonObject_IntOf(jResp,"attachment.size");
commentStart = CkJsonObject_IntOf(jResp,"comment.start");
commentLimit = CkJsonObject_IntOf(jResp,"comment.limit");
commentSize = CkJsonObject_IntOf(jResp,"comment.size");
pageStart = CkJsonObject_IntOf(jResp,"page.start");
pageLimit = CkJsonObject_IntOf(jResp,"page.limit");
pageSize = CkJsonObject_IntOf(jResp,"page.size");
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"attachment.results");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
value = CkJsonObject_stringOf(jResp,"attachment.results[i].value");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"comment.results");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
value = CkJsonObject_stringOf(jResp,"comment.results[i].value");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"page.results");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
value = CkJsonObject_stringOf(jResp,"page.results[i].value");
i = i + 1;
}
CkHttp_Dispose(http);
CkJsonObject_Dispose(queryParams);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
}
Curl Command
curl -G -d "expand=%3Cstring%3E"
-d "expand=%3Cstring%3E"
-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/content/:id/descendant
Postman Collection Item JSON
{
"name": "Get content descendants",
"request": {
"auth": {
"type": "oauth2"
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/content/:id/descendant?expand=<string>&expand=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"content",
":id",
"descendant"
],
"query": [
{
"key": "expand",
"value": "<string>",
"description": "A multi-value parameter indicating which properties of the children to\nexpand, where:\n\n- `attachment` returns all attachments for the content.\n- `comments` returns all comments for the content.\n- `page` returns all child pages of the content."
},
{
"key": "expand",
"value": "<string>",
"description": "A multi-value parameter indicating which properties of the children to\nexpand, where:\n\n- `attachment` returns all attachments for the content.\n- `comments` returns all comments for the content.\n- `page` returns all child pages of the content."
}
],
"variable": [
{
"key": "id",
"value": "<string>",
"type": "string",
"description": "(Required) The ID of the content to be queried for its descendants."
}
]
},
"description": "Returns a map of the descendants of a piece of content. This is similar\nto [Get content children](#api-content-id-child-get), except that this\nmethod returns child pages at all levels, rather than just the direct\nchild pages.\n\nA piece of content has different types of descendants, depending on its type:\n\n- `page`: descendant is `page`, `comment`, `attachment`\n- `blogpost`: descendant is `comment`, `attachment`\n- `attachment`: descendant is `comment`\n- `comment`: descendant is `attachment`\n\nThe map will always include all descendant types that are valid for the content.\nHowever, if the content has no instances of a descendant type, the map will\ncontain an empty array for that descendant type.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\n'View' permission for the space, and permission to view the content if it\nis a page."
},
"response": [
{
"name": "Returned if the requested descendants are returned.",
"originalRequest": {
"method": "GET",
"header": [
{
"description": {
"content": "Added as a part of security scheme: oauth2",
"type": "text/plain"
},
"key": "Authorization",
"value": "<token>"
}
],
"url": {
"raw": "{{baseUrl}}/api/content/:id/descendant?expand=<string>&expand=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"content",
":id",
"descendant"
],
"query": [
{
"key": "expand",
"value": "<string>"
},
{
"key": "expand",
"value": "<string>"
}
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"_expandable\": {\n \"attachment\": \"in ut\",\n \"comment\": \"dolor\",\n \"page\": \"eu exercitation\"\n },\n \"_links\": {},\n \"attachment\": {\n \"results\": [\n {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n },\n {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n }\n ],\n \"start\": -75729038,\n \"limit\": 34726306,\n \"size\": 18934279,\n \"_links\": {}\n },\n \"comment\": {\n \"results\": [\n {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n },\n {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n }\n ],\n \"start\": 37994470,\n \"limit\": 2587712,\n \"size\": -24049554,\n \"_links\": {}\n },\n \"page\": {\n \"results\": [\n {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n },\n {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n }\n ],\n \"start\": 66843073,\n \"limit\": 57682154,\n \"size\": -4004438,\n \"_links\": {}\n }\n}"
},
{
"name": "Returned if;\n\n- There is no content with the given ID.\n- The calling user does not have permission to view the content.",
"originalRequest": {
"method": "GET",
"header": [
{
"description": {
"content": "Added as a part of security scheme: oauth2",
"type": "text/plain"
},
"key": "Authorization",
"value": "<token>"
}
],
"url": {
"raw": "{{baseUrl}}/api/content/:id/descendant?expand=<string>&expand=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"content",
":id",
"descendant"
],
"query": [
{
"key": "expand",
"value": "<string>"
},
{
"key": "expand",
"value": "<string>"
}
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}