Back to Collection Items
#include <CkHttp.h>
#include <CkJsonObject.h>
#include <CkHttpResponse.h>
#include <CkStringBuilder.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http;
bool success;
CkJsonObject queryParams;
queryParams.UpdateString("expand","<string>");
queryParams.UpdateString("expand","<string>");
// Adds the "Authorization: Bearer <access_token>" header.
http.put_AuthToken("<access_token>");
CkHttpResponse *resp = http.QuickRequestParams("GET","https://your-domain.atlassian.net/wiki/rest/api/user/current",queryParams);
if (http.get_LastMethodSuccess() == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
CkStringBuilder sbResponseBody;
resp->GetBodySb(sbResponseBody);
CkJsonObject jResp;
jResp.LoadSb(sbResponseBody);
jResp.put_EmitCompact(false);
std::cout << "Response Body:" << "\r\n";
std::cout << jResp.emit() << "\r\n";
int respStatusCode = resp->get_StatusCode();
std::cout << "Response Status Code = " << respStatusCode << "\r\n";
if (respStatusCode >= 400) {
std::cout << "Response Header:" << "\r\n";
std::cout << resp->header() << "\r\n";
std::cout << "Failed." << "\r\n";
delete resp;
return;
}
delete resp;
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "type": "unknown",
// "accountId": "sit consectetur",
// "accountType": "atlassian",
// "email": "do",
// "publicName": "et nostrud mollit id",
// "profilePicture": {
// "path": "eiusmod Excepteur",
// "width": 61811707,
// "height": -27758421,
// "isDefault": true
// },
// "displayName": "eiusmod pariatur aliqua cupidatat",
// "_expandable": {
// "operations": "officia nu",
// "details": "exercitation ipsum elit tempor laborum",
// "personalSpace": "exercitation re"
// },
// "_links": {},
// "username": "sed velit Ut",
// "userKey": "labore anim",
// "operations": [
// {
// "operation": "use",
// "targetType": "application"
// },
// {
// "operation": "restore",
// "targetType": "space"
// }
// ],
// "details": {
// "business": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "personal": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "personalSpace": {
// "id": -69293677,
// "key": "minim",
// "name": "adipisicing minim nulla nisi consequat",
// "type": "reprehenderit",
// "status": "amet officia pariatur sed",
// "_expandable": {
// "settings": "deserunt dolore velit laborum",
// "metadata": "ullamco quis non sunt",
// "operations": "qui aliquip",
// "lookAndFeel": "eiusmod cillum ex",
// "permissions": "in ullamco",
// "icon": "veniam quis",
// "description": "officia adip",
// "theme": "ea nisi",
// "history": "aliquip est irure",
// "homepage": "aliqua est deserunt"
// },
// "_links": {},
// "icon": {
// "path": "adipisicing sed officia",
// "width": 33631448,
// "height": -10767970,
// "isDefault": true
// },
// "description": {
// "plain": {
// "value": "cupidatat nulla",
// "representation": "view",
// "embeddedContent": [
// {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// ]
// },
// "view": {
// "value": "magna aliquip ea",
// "representation": "plain",
// "embeddedContent": [
// {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// ]
// }
// },
// "homepage": {
// "value": "<Circular reference to #/components/schemas/Content detected>"
// },
// "metadata": {
// "labels": {
// "results": [
// {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// ],
// "start": 58105433,
// "limit": 10735114,
// "size": -29792214,
// "_links": {}
// }
// },
// "operations": [
// {
// "operation": "delete",
// "targetType": "blogpost"
// },
// {
// "operation": "restore",
// "targetType": "blogpost"
// }
// ],
// "permissions": [
// {
// "subjects": {
// "_expandable": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "user": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "group": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "operation": {
// "operation": "create",
// "targetType": "page"
// },
// "anonymousAccess": false,
// "unlicensedAccess": false
// },
// {
// "subjects": {
// "_expandable": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "user": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "group": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "operation": {
// "operation": "restore",
// "targetType": "blogpost"
// },
// "anonymousAccess": false,
// "unlicensedAccess": false
// }
// ],
// "settings": {
// "routeOverrideEnabled": false,
// "_links": {}
// },
// "theme": {},
// "lookAndFeel": {
// "headings": {
// "color": "<string>"
// },
// "links": {
// "color": "<string>"
// },
// "menus": {
// "hoverOrFocus": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "color": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "header": {
// "backgroundColor": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "button": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "primaryNavigation": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "secondaryNavigation": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "search": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "content": {
// "screen": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "container": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "header": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// },
// "body": {
// "value": "<Error: Too many levels of nesting to fake this schema>"
// }
// },
// "bordersAndDividers": {
// "color": "<string>"
// }
// },
// "history": {
// "createdDate": "2014-12-12T23:08:45.947Z"
// }
// }
// }
// 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 char *operation = 0;
const char *targetType = 0;
const char *value = 0;
const char *v_expandableValue = 0;
const char *UserValue = 0;
const char *GroupValue = 0;
const char *Operation = 0;
const char *TargetType = 0;
bool anonymousAccess;
bool unlicensedAccess;
const char *v_type = jResp.stringOf("type");
const char *accountId = jResp.stringOf("accountId");
const char *accountType = jResp.stringOf("accountType");
const char *email = jResp.stringOf("email");
const char *publicName = jResp.stringOf("publicName");
const char *Path = jResp.stringOf("profilePicture.path");
int Width = jResp.IntOf("profilePicture.width");
int Height = jResp.IntOf("profilePicture.height");
bool IsDefault = jResp.BoolOf("profilePicture.isDefault");
const char *displayName = jResp.stringOf("displayName");
const char *Operations = jResp.stringOf("_expandable.operations");
const char *Details = jResp.stringOf("_expandable.details");
const char *PersonalSpace = jResp.stringOf("_expandable.personalSpace");
const char *username = jResp.stringOf("username");
const char *userKey = jResp.stringOf("userKey");
const char *Value = jResp.stringOf("details.business.value");
const char *PersonalValue = jResp.stringOf("details.personal.value");
int Id = jResp.IntOf("personalSpace.id");
const char *Key = jResp.stringOf("personalSpace.key");
const char *Name = jResp.stringOf("personalSpace.name");
const char *v_Type = jResp.stringOf("personalSpace.type");
const char *Status = jResp.stringOf("personalSpace.status");
const char *Settings = jResp.stringOf("personalSpace._expandable.settings");
const char *Metadata = jResp.stringOf("personalSpace._expandable.metadata");
const char *v_expandableOperations = jResp.stringOf("personalSpace._expandable.operations");
const char *LookAndFeel = jResp.stringOf("personalSpace._expandable.lookAndFeel");
const char *Permissions = jResp.stringOf("personalSpace._expandable.permissions");
const char *Icon = jResp.stringOf("personalSpace._expandable.icon");
const char *Description = jResp.stringOf("personalSpace._expandable.description");
const char *Theme = jResp.stringOf("personalSpace._expandable.theme");
const char *History = jResp.stringOf("personalSpace._expandable.history");
const char *Homepage = jResp.stringOf("personalSpace._expandable.homepage");
const char *IconPath = jResp.stringOf("personalSpace.icon.path");
int IconWidth = jResp.IntOf("personalSpace.icon.width");
int IconHeight = jResp.IntOf("personalSpace.icon.height");
bool IconIsDefault = jResp.BoolOf("personalSpace.icon.isDefault");
const char *PlainValue = jResp.stringOf("personalSpace.description.plain.value");
const char *Representation = jResp.stringOf("personalSpace.description.plain.representation");
const char *ViewValue = jResp.stringOf("personalSpace.description.view.value");
const char *ViewRepresentation = jResp.stringOf("personalSpace.description.view.representation");
const char *HomepageValue = jResp.stringOf("personalSpace.homepage.value");
int Start = jResp.IntOf("personalSpace.metadata.labels.start");
int Limit = jResp.IntOf("personalSpace.metadata.labels.limit");
int Size = jResp.IntOf("personalSpace.metadata.labels.size");
bool RouteOverrideEnabled = jResp.BoolOf("personalSpace.settings.routeOverrideEnabled");
const char *Color = jResp.stringOf("personalSpace.lookAndFeel.headings.color");
const char *LinksColor = jResp.stringOf("personalSpace.lookAndFeel.links.color");
const char *HoverOrFocusValue = jResp.stringOf("personalSpace.lookAndFeel.menus.hoverOrFocus.value");
const char *ColorValue = jResp.stringOf("personalSpace.lookAndFeel.menus.color.value");
const char *BackgroundColorValue = jResp.stringOf("personalSpace.lookAndFeel.header.backgroundColor.value");
const char *ButtonValue = jResp.stringOf("personalSpace.lookAndFeel.header.button.value");
const char *PrimaryNavigationValue = jResp.stringOf("personalSpace.lookAndFeel.header.primaryNavigation.value");
const char *SecondaryNavigationValue = jResp.stringOf("personalSpace.lookAndFeel.header.secondaryNavigation.value");
const char *SearchValue = jResp.stringOf("personalSpace.lookAndFeel.header.search.value");
const char *ScreenValue = jResp.stringOf("personalSpace.lookAndFeel.content.screen.value");
const char *ContainerValue = jResp.stringOf("personalSpace.lookAndFeel.content.container.value");
const char *HeaderValue = jResp.stringOf("personalSpace.lookAndFeel.content.header.value");
const char *BodyValue = jResp.stringOf("personalSpace.lookAndFeel.content.body.value");
const char *BordersAndDividersColor = jResp.stringOf("personalSpace.lookAndFeel.bordersAndDividers.color");
const char *CreatedDate = jResp.stringOf("personalSpace.history.createdDate");
int i = 0;
int count_i = jResp.SizeOfArray("operations");
while (i < count_i) {
jResp.put_I(i);
operation = jResp.stringOf("operations[i].operation");
targetType = jResp.stringOf("operations[i].targetType");
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray("personalSpace.description.plain.embeddedContent");
while (i < count_i) {
jResp.put_I(i);
value = jResp.stringOf("personalSpace.description.plain.embeddedContent[i].value");
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray("personalSpace.description.view.embeddedContent");
while (i < count_i) {
jResp.put_I(i);
value = jResp.stringOf("personalSpace.description.view.embeddedContent[i].value");
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray("personalSpace.metadata.labels.results");
while (i < count_i) {
jResp.put_I(i);
value = jResp.stringOf("personalSpace.metadata.labels.results[i].value");
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray("personalSpace.operations");
while (i < count_i) {
jResp.put_I(i);
operation = jResp.stringOf("personalSpace.operations[i].operation");
targetType = jResp.stringOf("personalSpace.operations[i].targetType");
i = i + 1;
}
i = 0;
count_i = jResp.SizeOfArray("personalSpace.permissions");
while (i < count_i) {
jResp.put_I(i);
v_expandableValue = jResp.stringOf("personalSpace.permissions[i].subjects._expandable.value");
UserValue = jResp.stringOf("personalSpace.permissions[i].subjects.user.value");
GroupValue = jResp.stringOf("personalSpace.permissions[i].subjects.group.value");
Operation = jResp.stringOf("personalSpace.permissions[i].operation.operation");
TargetType = jResp.stringOf("personalSpace.permissions[i].operation.targetType");
anonymousAccess = jResp.BoolOf("personalSpace.permissions[i].anonymousAccess");
unlicensedAccess = jResp.BoolOf("personalSpace.permissions[i].unlicensedAccess");
i = i + 1;
}
}
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/user/current
Postman Collection Item JSON
{
"name": "Get current user",
"request": {
"auth": {
"type": "oauth2"
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/user/current?expand=<string>&expand=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"user",
"current"
],
"query": [
{
"key": "expand",
"value": "<string>",
"description": "A multi-value parameter indicating which properties of the user to\nexpand.\n\n - `operations` returns the operations that the user is allowed to do.\n - `details.personal` returns the 'Personal' details in the user's profile, like the 'Email' and 'Phone'.\n Note that these fields have been deprecated due to privacy changes. See the\n [migration guide](https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/)\n for details.\n - `details.business` returns the 'Company' details in the user's profile, like the 'Position' and 'Department'.\n Note that these fields have been deprecated due to privacy changes. See the\n [migration guide](https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/)\n for details.\n - personalSpace returns the user's personal space, if it exists."
},
{
"key": "expand",
"value": "<string>",
"description": "A multi-value parameter indicating which properties of the user to\nexpand.\n\n - `operations` returns the operations that the user is allowed to do.\n - `details.personal` returns the 'Personal' details in the user's profile, like the 'Email' and 'Phone'.\n Note that these fields have been deprecated due to privacy changes. See the\n [migration guide](https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/)\n for details.\n - `details.business` returns the 'Company' details in the user's profile, like the 'Position' and 'Department'.\n Note that these fields have been deprecated due to privacy changes. See the\n [migration guide](https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/)\n for details.\n - personalSpace returns the user's personal space, if it exists."
}
]
},
"description": "Returns the currently logged-in user. This includes information about\nthe user, like the display name, userKey, account ID, profile picture,\nand more.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\nPermission to access the Confluence site ('Can use' global permission)."
},
"response": [
{
"name": "Returned if the current user 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/user/current?expand=<string>&expand=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"user",
"current"
],
"query": [
{
"key": "expand",
"value": "<string>"
},
{
"key": "expand",
"value": "<string>"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"type\": \"unknown\",\n \"accountId\": \"sit consectetur\",\n \"accountType\": \"atlassian\",\n \"email\": \"do\",\n \"publicName\": \"et nostrud mollit id\",\n \"profilePicture\": {\n \"path\": \"eiusmod Excepteur\",\n \"width\": 61811707,\n \"height\": -27758421,\n \"isDefault\": true\n },\n \"displayName\": \"eiusmod pariatur aliqua cupidatat\",\n \"_expandable\": {\n \"operations\": \"officia nu\",\n \"details\": \"exercitation ipsum elit tempor laborum\",\n \"personalSpace\": \"exercitation re\"\n },\n \"_links\": {},\n \"username\": \"sed velit Ut\",\n \"userKey\": \"labore anim\",\n \"operations\": [\n {\n \"operation\": \"use\",\n \"targetType\": \"application\"\n },\n {\n \"operation\": \"restore\",\n \"targetType\": \"space\"\n }\n ],\n \"details\": {\n \"business\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"personal\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"personalSpace\": {\n \"id\": -69293677,\n \"key\": \"minim\",\n \"name\": \"adipisicing minim nulla nisi consequat\",\n \"type\": \"reprehenderit\",\n \"status\": \"amet officia pariatur sed\",\n \"_expandable\": {\n \"settings\": \"deserunt dolore velit laborum\",\n \"metadata\": \"ullamco quis non sunt\",\n \"operations\": \"qui aliquip\",\n \"lookAndFeel\": \"eiusmod cillum ex\",\n \"permissions\": \"in ullamco\",\n \"icon\": \"veniam quis\",\n \"description\": \"officia adip\",\n \"theme\": \"ea nisi\",\n \"history\": \"aliquip est irure\",\n \"homepage\": \"aliqua est deserunt\"\n },\n \"_links\": {},\n \"icon\": {\n \"path\": \"adipisicing sed officia\",\n \"width\": 33631448,\n \"height\": -10767970,\n \"isDefault\": true\n },\n \"description\": {\n \"plain\": {\n \"value\": \"cupidatat nulla\",\n \"representation\": \"view\",\n \"embeddedContent\": [\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 },\n \"view\": {\n \"value\": \"magna aliquip ea\",\n \"representation\": \"plain\",\n \"embeddedContent\": [\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 }\n },\n \"homepage\": {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n },\n \"metadata\": {\n \"labels\": {\n \"results\": [\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 \"start\": 58105433,\n \"limit\": 10735114,\n \"size\": -29792214,\n \"_links\": {}\n }\n },\n \"operations\": [\n {\n \"operation\": \"delete\",\n \"targetType\": \"blogpost\"\n },\n {\n \"operation\": \"restore\",\n \"targetType\": \"blogpost\"\n }\n ],\n \"permissions\": [\n {\n \"subjects\": {\n \"_expandable\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"user\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"group\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"operation\": {\n \"operation\": \"create\",\n \"targetType\": \"page\"\n },\n \"anonymousAccess\": false,\n \"unlicensedAccess\": false\n },\n {\n \"subjects\": {\n \"_expandable\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"user\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"group\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"operation\": {\n \"operation\": \"restore\",\n \"targetType\": \"blogpost\"\n },\n \"anonymousAccess\": false,\n \"unlicensedAccess\": false\n }\n ],\n \"settings\": {\n \"routeOverrideEnabled\": false,\n \"_links\": {}\n },\n \"theme\": {},\n \"lookAndFeel\": {\n \"headings\": {\n \"color\": \"<string>\"\n },\n \"links\": {\n \"color\": \"<string>\"\n },\n \"menus\": {\n \"hoverOrFocus\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"color\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"header\": {\n \"backgroundColor\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"button\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"primaryNavigation\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"secondaryNavigation\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"search\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"content\": {\n \"screen\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"container\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"header\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"body\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"bordersAndDividers\": {\n \"color\": \"<string>\"\n }\n },\n \"history\": {\n \"createdDate\": \"2014-12-12T23:08:45.947Z\"\n }\n }\n}"
},
{
"name": "Returned if the calling user does not have permission to use\nConfluence.",
"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/user/current?expand=<string>&expand=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"user",
"current"
],
"query": [
{
"key": "expand",
"value": "<string>"
},
{
"key": "expand",
"value": "<string>"
}
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}