Back to Collection Items
#include <CkHttpW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.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;
// Adds the "Authorization: Bearer <access_token>" header.
http.put_AuthToken(L"<access_token>");
CkStringBuilderW sbResponseBody;
success = http.QuickGetSb(L"https://domain.com/services/data/v{{version}}/connect/files/:FILE_ID",sbResponseBody);
if (success == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
CkJsonObjectW jResp;
jResp.LoadSb(sbResponseBody);
jResp.put_EmitCompact(false);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",jResp.emit());
int respStatusCode = http.get_LastStatus();
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",http.lastHeader());
wprintf(L"Failed.\n");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "checksum": "71a50dbba44c78128b221b7df7bb51f1",
// "contentHubRepository": null,
// "contentModifiedDate": "2023-11-20T16:28:22.000Z",
// "contentSize": 95,
// "contentUrl": null,
// "createdDate": "2023-11-20T16:28:22.000Z",
// "description": null,
// "downloadUrl": "/services/data/v58.0/connect/files/069.../content?versionNumber=1",
// "externalDocumentUrl": null,
// "externalFilePermissionInformation": null,
// "fileAsset": null,
// "fileExtension": "png",
// "fileType": "Png",
// "flashRenditionStatus": "Na",
// "id": "069...",
// "isFileAsset": false,
// "isInMyFileSync": false,
// "isMajorVersion": true,
// "mimeType": "image/png",
// "moderationFlags": null,
// "modifiedDate": "2023-11-20T16:28:22.000Z",
// "motif": {
// "color": "939393",
// "largeIconUrl": "/img/content/content64.png",
// "mediumIconUrl": "/img/content/content32.png",
// "smallIconUrl": "/img/icon/files16.png",
// "svgIconUrl": null
// },
// "mySubscription": null,
// "name": "1x1.png",
// "origin": "Chatter",
// "owner": {
// "additionalLabel": null,
// "communityNickname": "User1696423780773910041",
// "companyName": "Salesforce",
// "displayName": "Name",
// "firstName": "firstName",
// "id": "005...",
// "isActive": true,
// "isInThisCommunity": true,
// "lastName": "Name",
// "motif": {
// "color": "1B96FF",
// "largeIconUrl": "/img/icon/profile64.png",
// "mediumIconUrl": "/img/icon/profile32.png",
// "smallIconUrl": "/img/icon/profile16.png",
// "svgIconUrl": null
// },
// "mySubscription": null,
// "name": "Name",
// "outOfOffice": {
// "message": ""
// },
// "photo": {
// "fullEmailPhotoUrl": "https://<my_domain>/ncsphoto/1wsMlOd3tVC7boygqBO8wMT9KzA0D6tqzpbs-Uw0IogXzXAXaYKJnuWCNQmXymRq?fromEmail=1",
// "largePhotoUrl": "https://<my_domain>/profilephoto/729.../F",
// "mediumPhotoUrl": "https://<my_domain>/profilephoto/729.../M",
// "photoVersionId": "729...",
// "smallPhotoUrl": "https://<my_domain>/profilephoto/729.../T",
// "standardEmailPhotoUrl": "https://<my_domain>/ncsphoto/1wsMlOd3tVC7boygqBO8wMT9KzA0D6tqzpbs-Uw0Ioi-dtynkoFWsl46as__TDFU?fromEmail=1",
// "url": "/services/data/v58.0/connect/user-profiles/005.../photo"
// },
// "reputation": null,
// "title": null,
// "type": "User",
// "url": "/services/data/v58.0/chatter/users/005...",
// "userType": "Internal"
// },
// "pageCount": 0,
// "parentFolder": null,
// "pdfRenditionStatus": "Na",
// "publishStatus": "PrivateAccess",
// "renditionUrl": "/services/data/v58.0/connect/files/069.../rendition?type=THUMB120BY90",
// "renditionUrl240By180": "/services/data/v58.0/connect/files/069.../rendition?type=THUMB240BY180",
// "renditionUrl720By480": "/services/data/v58.0/connect/files/069.../rendition?type=THUMB720BY480",
// "repositoryFileId": null,
// "repositoryFileUrl": null,
// "sharingOption": "Allowed",
// "sharingPrivacy": "None",
// "sharingRole": "Owner",
// "systemModstamp": "2023-11-20T16:28:23.000Z",
// "textPreview": null,
// "thumb120By90RenditionStatus": "NotScheduled",
// "thumb240By180RenditionStatus": "NotScheduled",
// "thumb720By480RenditionStatus": "NotScheduled",
// "title": "1x1.png",
// "topics": {
// "currentPageUrl": null,
// "nextPageUrl": null,
// "topics": [
// ]
// },
// "type": "File",
// "url": "/services/data/v58.0/connect/files/069...?versionNumber=1",
// "versionNumber": "1"
// }
// 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 *checksum = jResp.stringOf(L"checksum");
const wchar_t *contentHubRepository = jResp.stringOf(L"contentHubRepository");
const wchar_t *contentModifiedDate = jResp.stringOf(L"contentModifiedDate");
int contentSize = jResp.IntOf(L"contentSize");
const wchar_t *contentUrl = jResp.stringOf(L"contentUrl");
const wchar_t *createdDate = jResp.stringOf(L"createdDate");
const wchar_t *description = jResp.stringOf(L"description");
const wchar_t *downloadUrl = jResp.stringOf(L"downloadUrl");
const wchar_t *externalDocumentUrl = jResp.stringOf(L"externalDocumentUrl");
const wchar_t *externalFilePermissionInformation = jResp.stringOf(L"externalFilePermissionInformation");
const wchar_t *fileAsset = jResp.stringOf(L"fileAsset");
const wchar_t *fileExtension = jResp.stringOf(L"fileExtension");
const wchar_t *fileType = jResp.stringOf(L"fileType");
const wchar_t *flashRenditionStatus = jResp.stringOf(L"flashRenditionStatus");
const wchar_t *id = jResp.stringOf(L"id");
bool isFileAsset = jResp.BoolOf(L"isFileAsset");
bool isInMyFileSync = jResp.BoolOf(L"isInMyFileSync");
bool isMajorVersion = jResp.BoolOf(L"isMajorVersion");
const wchar_t *mimeType = jResp.stringOf(L"mimeType");
const wchar_t *moderationFlags = jResp.stringOf(L"moderationFlags");
const wchar_t *modifiedDate = jResp.stringOf(L"modifiedDate");
const wchar_t *Color = jResp.stringOf(L"motif.color");
const wchar_t *LargeIconUrl = jResp.stringOf(L"motif.largeIconUrl");
const wchar_t *MediumIconUrl = jResp.stringOf(L"motif.mediumIconUrl");
const wchar_t *SmallIconUrl = jResp.stringOf(L"motif.smallIconUrl");
const wchar_t *SvgIconUrl = jResp.stringOf(L"motif.svgIconUrl");
const wchar_t *mySubscription = jResp.stringOf(L"mySubscription");
const wchar_t *name = jResp.stringOf(L"name");
const wchar_t *origin = jResp.stringOf(L"origin");
const wchar_t *AdditionalLabel = jResp.stringOf(L"owner.additionalLabel");
const wchar_t *CommunityNickname = jResp.stringOf(L"owner.communityNickname");
const wchar_t *CompanyName = jResp.stringOf(L"owner.companyName");
const wchar_t *DisplayName = jResp.stringOf(L"owner.displayName");
const wchar_t *FirstName = jResp.stringOf(L"owner.firstName");
const wchar_t *Id = jResp.stringOf(L"owner.id");
bool IsActive = jResp.BoolOf(L"owner.isActive");
bool IsInThisCommunity = jResp.BoolOf(L"owner.isInThisCommunity");
const wchar_t *LastName = jResp.stringOf(L"owner.lastName");
const wchar_t *MotifColor = jResp.stringOf(L"owner.motif.color");
const wchar_t *MotifLargeIconUrl = jResp.stringOf(L"owner.motif.largeIconUrl");
const wchar_t *MotifMediumIconUrl = jResp.stringOf(L"owner.motif.mediumIconUrl");
const wchar_t *MotifSmallIconUrl = jResp.stringOf(L"owner.motif.smallIconUrl");
const wchar_t *MotifSvgIconUrl = jResp.stringOf(L"owner.motif.svgIconUrl");
const wchar_t *MySubscription = jResp.stringOf(L"owner.mySubscription");
const wchar_t *Name = jResp.stringOf(L"owner.name");
const wchar_t *Message = jResp.stringOf(L"owner.outOfOffice.message");
const wchar_t *FullEmailPhotoUrl = jResp.stringOf(L"owner.photo.fullEmailPhotoUrl");
const wchar_t *LargePhotoUrl = jResp.stringOf(L"owner.photo.largePhotoUrl");
const wchar_t *MediumPhotoUrl = jResp.stringOf(L"owner.photo.mediumPhotoUrl");
const wchar_t *PhotoVersionId = jResp.stringOf(L"owner.photo.photoVersionId");
const wchar_t *SmallPhotoUrl = jResp.stringOf(L"owner.photo.smallPhotoUrl");
const wchar_t *StandardEmailPhotoUrl = jResp.stringOf(L"owner.photo.standardEmailPhotoUrl");
const wchar_t *v_Url = jResp.stringOf(L"owner.photo.url");
const wchar_t *Reputation = jResp.stringOf(L"owner.reputation");
const wchar_t *Title = jResp.stringOf(L"owner.title");
const wchar_t *v_Type = jResp.stringOf(L"owner.type");
const wchar_t *ownerUrl = jResp.stringOf(L"owner.url");
const wchar_t *UserType = jResp.stringOf(L"owner.userType");
int pageCount = jResp.IntOf(L"pageCount");
const wchar_t *parentFolder = jResp.stringOf(L"parentFolder");
const wchar_t *pdfRenditionStatus = jResp.stringOf(L"pdfRenditionStatus");
const wchar_t *publishStatus = jResp.stringOf(L"publishStatus");
const wchar_t *renditionUrl = jResp.stringOf(L"renditionUrl");
const wchar_t *renditionUrl240By180 = jResp.stringOf(L"renditionUrl240By180");
const wchar_t *renditionUrl720By480 = jResp.stringOf(L"renditionUrl720By480");
const wchar_t *repositoryFileId = jResp.stringOf(L"repositoryFileId");
const wchar_t *repositoryFileUrl = jResp.stringOf(L"repositoryFileUrl");
const wchar_t *sharingOption = jResp.stringOf(L"sharingOption");
const wchar_t *sharingPrivacy = jResp.stringOf(L"sharingPrivacy");
const wchar_t *sharingRole = jResp.stringOf(L"sharingRole");
const wchar_t *systemModstamp = jResp.stringOf(L"systemModstamp");
const wchar_t *textPreview = jResp.stringOf(L"textPreview");
const wchar_t *thumb120By90RenditionStatus = jResp.stringOf(L"thumb120By90RenditionStatus");
const wchar_t *thumb240By180RenditionStatus = jResp.stringOf(L"thumb240By180RenditionStatus");
const wchar_t *thumb720By480RenditionStatus = jResp.stringOf(L"thumb720By480RenditionStatus");
const wchar_t *title = jResp.stringOf(L"title");
const wchar_t *CurrentPageUrl = jResp.stringOf(L"topics.currentPageUrl");
const wchar_t *NextPageUrl = jResp.stringOf(L"topics.nextPageUrl");
const wchar_t *v_type = jResp.stringOf(L"type");
const wchar_t *url = jResp.stringOf(L"url");
const wchar_t *versionNumber = jResp.stringOf(L"versionNumber");
int i = 0;
int count_i = jResp.SizeOfArray(L"topics.topics");
while (i < count_i) {
jResp.put_I(i);
i = i + 1;
}
}
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://domain.com/services/data/v{{version}}/connect/files/:FILE_ID
Postman Collection Item JSON
{
"name": "File Information",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {}
},
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/files/:FILE_ID",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"files",
":FILE_ID"
],
"variable": [
{
"key": "FILE_ID",
"value": ""
}
]
},
"description": "Get information about a specified file, including references to external files. Upload a new version of an existing file, including references to external files. Rename a file, move a file to a different folder, and delete a file.\nTo upload a new version of an existing file, make a POST request. Upload the new version as a binary part in a multipart/form-data request. See Uploading Binary Files. To upload a new file to the Files home, use /connect/files/users/me.Get information about a specified file, including references to external files.\nhttps://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_files_information.htm"
},
"response": [
{
"name": "File Information",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/files/:FILE_ID",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"files",
":FILE_ID"
],
"variable": [
{
"key": "FILE_ID",
"value": "0692o00000woaKjAAI"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Mon, 20 Nov 2023 16:33:38 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "{\n \"checksum\": \"71a50dbba44c78128b221b7df7bb51f1\",\n \"contentHubRepository\": null,\n \"contentModifiedDate\": \"2023-11-20T16:28:22.000Z\",\n \"contentSize\": 95,\n \"contentUrl\": null,\n \"createdDate\": \"2023-11-20T16:28:22.000Z\",\n \"description\": null,\n \"downloadUrl\": \"/services/data/v58.0/connect/files/069.../content?versionNumber=1\",\n \"externalDocumentUrl\": null,\n \"externalFilePermissionInformation\": null,\n \"fileAsset\": null,\n \"fileExtension\": \"png\",\n \"fileType\": \"Png\",\n \"flashRenditionStatus\": \"Na\",\n \"id\": \"069...\",\n \"isFileAsset\": false,\n \"isInMyFileSync\": false,\n \"isMajorVersion\": true,\n \"mimeType\": \"image/png\",\n \"moderationFlags\": null,\n \"modifiedDate\": \"2023-11-20T16:28:22.000Z\",\n \"motif\": {\n \"color\": \"939393\",\n \"largeIconUrl\": \"/img/content/content64.png\",\n \"mediumIconUrl\": \"/img/content/content32.png\",\n \"smallIconUrl\": \"/img/icon/files16.png\",\n \"svgIconUrl\": null\n },\n \"mySubscription\": null,\n \"name\": \"1x1.png\",\n \"origin\": \"Chatter\",\n \"owner\": {\n \"additionalLabel\": null,\n \"communityNickname\": \"User1696423780773910041\",\n \"companyName\": \"Salesforce\",\n \"displayName\": \"Name\",\n \"firstName\": \"firstName\",\n \"id\": \"005...\",\n \"isActive\": true,\n \"isInThisCommunity\": true,\n \"lastName\": \"Name\",\n \"motif\": {\n \"color\": \"1B96FF\",\n \"largeIconUrl\": \"/img/icon/profile64.png\",\n \"mediumIconUrl\": \"/img/icon/profile32.png\",\n \"smallIconUrl\": \"/img/icon/profile16.png\",\n \"svgIconUrl\": null\n },\n \"mySubscription\": null,\n \"name\": \"Name\",\n \"outOfOffice\": {\n \"message\": \"\"\n },\n \"photo\": {\n \"fullEmailPhotoUrl\": \"https://<my_domain>/ncsphoto/1wsMlOd3tVC7boygqBO8wMT9KzA0D6tqzpbs-Uw0IogXzXAXaYKJnuWCNQmXymRq?fromEmail=1\",\n \"largePhotoUrl\": \"https://<my_domain>/profilephoto/729.../F\",\n \"mediumPhotoUrl\": \"https://<my_domain>/profilephoto/729.../M\",\n \"photoVersionId\": \"729...\",\n \"smallPhotoUrl\": \"https://<my_domain>/profilephoto/729.../T\",\n \"standardEmailPhotoUrl\": \"https://<my_domain>/ncsphoto/1wsMlOd3tVC7boygqBO8wMT9KzA0D6tqzpbs-Uw0Ioi-dtynkoFWsl46as__TDFU?fromEmail=1\",\n \"url\": \"/services/data/v58.0/connect/user-profiles/005.../photo\"\n },\n \"reputation\": null,\n \"title\": null,\n \"type\": \"User\",\n \"url\": \"/services/data/v58.0/chatter/users/005...\",\n \"userType\": \"Internal\"\n },\n \"pageCount\": 0,\n \"parentFolder\": null,\n \"pdfRenditionStatus\": \"Na\",\n \"publishStatus\": \"PrivateAccess\",\n \"renditionUrl\": \"/services/data/v58.0/connect/files/069.../rendition?type=THUMB120BY90\",\n \"renditionUrl240By180\": \"/services/data/v58.0/connect/files/069.../rendition?type=THUMB240BY180\",\n \"renditionUrl720By480\": \"/services/data/v58.0/connect/files/069.../rendition?type=THUMB720BY480\",\n \"repositoryFileId\": null,\n \"repositoryFileUrl\": null,\n \"sharingOption\": \"Allowed\",\n \"sharingPrivacy\": \"None\",\n \"sharingRole\": \"Owner\",\n \"systemModstamp\": \"2023-11-20T16:28:23.000Z\",\n \"textPreview\": null,\n \"thumb120By90RenditionStatus\": \"NotScheduled\",\n \"thumb240By180RenditionStatus\": \"NotScheduled\",\n \"thumb720By480RenditionStatus\": \"NotScheduled\",\n \"title\": \"1x1.png\",\n \"topics\": {\n \"currentPageUrl\": null,\n \"nextPageUrl\": null,\n \"topics\": []\n },\n \"type\": \"File\",\n \"url\": \"/services/data/v58.0/connect/files/069...?versionNumber=1\",\n \"versionNumber\": \"1\"\n}"
}
]
}