Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; Adds the "Authorization: Bearer <access_token>" header.
CkHttp::setCkAuthToken(http, "<access_token>")
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkHttp::ckQuickGetSb(http,"https://your-domain.atlassian.net/wiki/rest/api/template/:contentTemplateId",sbResponseBody)
If success = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
jResp.i = CkJsonObject::ckCreate()
If jResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(jResp,sbResponseBody)
CkJsonObject::setCkEmitCompact(jResp, 0)
Debug "Response Body:"
Debug CkJsonObject::ckEmit(jResp)
respStatusCode.i = CkHttp::ckLastStatus(http)
Debug "Response Status Code = " + Str(respStatusCode)
If respStatusCode >= 400
Debug "Response Header:"
Debug CkHttp::ckLastHeader(http)
Debug "Failed."
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndIf
; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)
; {
; "templateId": "id ipsum ut",
; "name": "sit dolor sint dolore",
; "description": "magna",
; "labels": [
; {
; "prefix": "fugiat sit Ut in ea",
; "name": "dolor in",
; "id": "aliqua culpa veniam ea",
; "label": "officia tempor ea"
; },
; {
; "prefix": "exercitation culpa proident",
; "name": "nulla mollit adipis",
; "id": "laborum sint",
; "label": "fugiat"
; }
; ],
; "templateType": "in cillum",
; "_expandable": {
; "body": "anim aute officia in culpa"
; },
; "_links": {},
; "body": {
; "value": "aute sit pariatur consequat deserunt",
; "representation": "anonymous_export_view",
; "_expandable": {
; "content": "nulla cillum reprehenderit"
; },
; "embeddedContent": [
; {
; "entityId": {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; },
; "entity": {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; }
; },
; {
; "entityId": {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; },
; "entity": {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; }
; }
; ],
; "webresource": {
; "keys": [
; {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; },
; {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; }
; ],
; "contexts": [
; {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; },
; {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; }
; ],
; "uris": {
; "all": {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; },
; "css": {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; },
; "js": {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; }
; },
; "tags": {
; "all": {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; },
; "css": {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; },
; "data": {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; },
; "js": {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; }
; },
; "superbatch": {
; "value": "<Error: Too many levels of nesting to fake this schema>"
; }
; }
; }
; }
; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
prefix.s
id.s
label.s
entityIdValue.s
entityValue.s
value.s
templateId.s = CkJsonObject::ckStringOf(jResp,"templateId")
name.s = CkJsonObject::ckStringOf(jResp,"name")
description.s = CkJsonObject::ckStringOf(jResp,"description")
templateType.s = CkJsonObject::ckStringOf(jResp,"templateType")
Body.s = CkJsonObject::ckStringOf(jResp,"_expandable.body")
Value.s = CkJsonObject::ckStringOf(jResp,"body.value")
Representation.s = CkJsonObject::ckStringOf(jResp,"body.representation")
Content.s = CkJsonObject::ckStringOf(jResp,"body._expandable.content")
AllValue.s = CkJsonObject::ckStringOf(jResp,"body.webresource.uris.all.value")
CssValue.s = CkJsonObject::ckStringOf(jResp,"body.webresource.uris.css.value")
JsValue.s = CkJsonObject::ckStringOf(jResp,"body.webresource.uris.js.value")
AllValue = CkJsonObject::ckStringOf(jResp,"body.webresource.tags.all.value")
CssValue = CkJsonObject::ckStringOf(jResp,"body.webresource.tags.css.value")
DataValue.s = CkJsonObject::ckStringOf(jResp,"body.webresource.tags.data.value")
JsValue = CkJsonObject::ckStringOf(jResp,"body.webresource.tags.js.value")
SuperbatchValue.s = CkJsonObject::ckStringOf(jResp,"body.webresource.superbatch.value")
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(jResp,"labels")
While i < count_i
CkJsonObject::setCkI(jResp, i)
prefix = CkJsonObject::ckStringOf(jResp,"labels[i].prefix")
name = CkJsonObject::ckStringOf(jResp,"labels[i].name")
id = CkJsonObject::ckStringOf(jResp,"labels[i].id")
label = CkJsonObject::ckStringOf(jResp,"labels[i].label")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(jResp,"body.embeddedContent")
While i < count_i
CkJsonObject::setCkI(jResp, i)
entityIdValue = CkJsonObject::ckStringOf(jResp,"body.embeddedContent[i].entityId.value")
entityValue = CkJsonObject::ckStringOf(jResp,"body.embeddedContent[i].entity.value")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(jResp,"body.webresource.keys")
While i < count_i
CkJsonObject::setCkI(jResp, i)
value = CkJsonObject::ckStringOf(jResp,"body.webresource.keys[i].value")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(jResp,"body.webresource.contexts")
While i < count_i
CkJsonObject::setCkI(jResp, i)
value = CkJsonObject::ckStringOf(jResp,"body.webresource.contexts[i].value")
i = i + 1
Wend
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/template/:contentTemplateId
Postman Collection Item JSON
{
"name": "Get content template",
"request": {
"auth": {
"type": "oauth2"
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/template/:contentTemplateId",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"template",
":contentTemplateId"
],
"variable": [
{
"key": "contentTemplateId",
"value": "<string>",
"type": "string",
"description": "(Required) The ID of the content template to be returned."
}
]
},
"description": "Returns a content template. This includes information about template,\nlike the name, the space or blueprint that the template is in, the body\nof the template, and more.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\n'Admin' permission for the space to view space templates and 'Confluence\nAdministrator' global permission to view global templates."
},
"response": [
{
"name": "Returned if the requested template is 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/template/:contentTemplateId",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"template",
":contentTemplateId"
],
"variable": [
{
"key": "contentTemplateId"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"templateId\": \"id ipsum ut\",\n \"name\": \"sit dolor sint dolore\",\n \"description\": \"magna\",\n \"labels\": [\n {\n \"prefix\": \"fugiat sit Ut in ea\",\n \"name\": \"dolor in\",\n \"id\": \"aliqua culpa veniam ea\",\n \"label\": \"officia tempor ea\"\n },\n {\n \"prefix\": \"exercitation culpa proident\",\n \"name\": \"nulla mollit adipis\",\n \"id\": \"laborum sint\",\n \"label\": \"fugiat\"\n }\n ],\n \"templateType\": \"in cillum\",\n \"_expandable\": {\n \"body\": \"anim aute officia in culpa\"\n },\n \"_links\": {},\n \"body\": {\n \"value\": \"aute sit pariatur consequat deserunt\",\n \"representation\": \"anonymous_export_view\",\n \"_expandable\": {\n \"content\": \"nulla cillum reprehenderit\"\n },\n \"embeddedContent\": [\n {\n \"entityId\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"entity\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n {\n \"entityId\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"entity\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n }\n ],\n \"webresource\": {\n \"keys\": [\n {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n ],\n \"contexts\": [\n {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n ],\n \"uris\": {\n \"all\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"css\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"js\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"tags\": {\n \"all\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"css\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"data\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"js\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"superbatch\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n }\n }\n}"
},
{
"name": "Returned if;\n\n- There is no template with the given ID.\n- The calling user does not have permission to view the template.",
"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/template/:contentTemplateId",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"template",
":contentTemplateId"
],
"variable": [
{
"key": "contentTemplateId"
}
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}