Chilkat Online Tools

C / Salesforce Platform APIs / File Information

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jResp;
    int respStatusCode;
    const char *checksum;
    const char *contentHubRepository;
    const char *contentModifiedDate;
    int contentSize;
    const char *contentUrl;
    const char *createdDate;
    const char *description;
    const char *downloadUrl;
    const char *externalDocumentUrl;
    const char *externalFilePermissionInformation;
    const char *fileAsset;
    const char *fileExtension;
    const char *fileType;
    const char *flashRenditionStatus;
    const char *id;
    BOOL isFileAsset;
    BOOL isInMyFileSync;
    BOOL isMajorVersion;
    const char *mimeType;
    const char *moderationFlags;
    const char *modifiedDate;
    const char *Color;
    const char *LargeIconUrl;
    const char *MediumIconUrl;
    const char *SmallIconUrl;
    const char *SvgIconUrl;
    const char *mySubscription;
    const char *name;
    const char *origin;
    const char *AdditionalLabel;
    const char *CommunityNickname;
    const char *CompanyName;
    const char *DisplayName;
    const char *FirstName;
    const char *Id;
    BOOL IsActive;
    BOOL IsInThisCommunity;
    const char *LastName;
    const char *MotifColor;
    const char *MotifLargeIconUrl;
    const char *MotifMediumIconUrl;
    const char *MotifSmallIconUrl;
    const char *MotifSvgIconUrl;
    const char *MySubscription;
    const char *Name;
    const char *Message;
    const char *FullEmailPhotoUrl;
    const char *LargePhotoUrl;
    const char *MediumPhotoUrl;
    const char *PhotoVersionId;
    const char *SmallPhotoUrl;
    const char *StandardEmailPhotoUrl;
    const char *v_Url;
    const char *Reputation;
    const char *Title;
    const char *v_Type;
    const char *ownerUrl;
    const char *UserType;
    int pageCount;
    const char *parentFolder;
    const char *pdfRenditionStatus;
    const char *publishStatus;
    const char *renditionUrl;
    const char *renditionUrl240By180;
    const char *renditionUrl720By480;
    const char *repositoryFileId;
    const char *repositoryFileUrl;
    const char *sharingOption;
    const char *sharingPrivacy;
    const char *sharingRole;
    const char *systemModstamp;
    const char *textPreview;
    const char *thumb120By90RenditionStatus;
    const char *thumb240By180RenditionStatus;
    const char *thumb720By480RenditionStatus;
    const char *title;
    const char *CurrentPageUrl;
    const char *NextPageUrl;
    const char *v_type;
    const char *url;
    const char *versionNumber;
    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();

    // Adds the "Authorization: Bearer <access_token>" header.
    CkHttp_putAuthToken(http,"<access_token>");

    sbResponseBody = CkStringBuilder_Create();
    success = CkHttp_QuickGetSb(http,"https://domain.com/services/data/v{{version}}/connect/files/:FILE_ID",sbResponseBody);
    if (success == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkStringBuilder_Dispose(sbResponseBody);
        return;
    }

    jResp = CkJsonObject_Create();
    CkJsonObject_LoadSb(jResp,sbResponseBody);
    CkJsonObject_putEmitCompact(jResp,FALSE);

    printf("Response Body:\n");
    printf("%s\n",CkJsonObject_emit(jResp));

    respStatusCode = CkHttp_getLastStatus(http);
    printf("Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        printf("Response Header:\n");
        printf("%s\n",CkHttp_lastHeader(http));
        printf("Failed.\n");
        CkHttp_Dispose(http);
        CkStringBuilder_Dispose(sbResponseBody);
        CkJsonObject_Dispose(jResp);
        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.

    checksum = CkJsonObject_stringOf(jResp,"checksum");
    contentHubRepository = CkJsonObject_stringOf(jResp,"contentHubRepository");
    contentModifiedDate = CkJsonObject_stringOf(jResp,"contentModifiedDate");
    contentSize = CkJsonObject_IntOf(jResp,"contentSize");
    contentUrl = CkJsonObject_stringOf(jResp,"contentUrl");
    createdDate = CkJsonObject_stringOf(jResp,"createdDate");
    description = CkJsonObject_stringOf(jResp,"description");
    downloadUrl = CkJsonObject_stringOf(jResp,"downloadUrl");
    externalDocumentUrl = CkJsonObject_stringOf(jResp,"externalDocumentUrl");
    externalFilePermissionInformation = CkJsonObject_stringOf(jResp,"externalFilePermissionInformation");
    fileAsset = CkJsonObject_stringOf(jResp,"fileAsset");
    fileExtension = CkJsonObject_stringOf(jResp,"fileExtension");
    fileType = CkJsonObject_stringOf(jResp,"fileType");
    flashRenditionStatus = CkJsonObject_stringOf(jResp,"flashRenditionStatus");
    id = CkJsonObject_stringOf(jResp,"id");
    isFileAsset = CkJsonObject_BoolOf(jResp,"isFileAsset");
    isInMyFileSync = CkJsonObject_BoolOf(jResp,"isInMyFileSync");
    isMajorVersion = CkJsonObject_BoolOf(jResp,"isMajorVersion");
    mimeType = CkJsonObject_stringOf(jResp,"mimeType");
    moderationFlags = CkJsonObject_stringOf(jResp,"moderationFlags");
    modifiedDate = CkJsonObject_stringOf(jResp,"modifiedDate");
    Color = CkJsonObject_stringOf(jResp,"motif.color");
    LargeIconUrl = CkJsonObject_stringOf(jResp,"motif.largeIconUrl");
    MediumIconUrl = CkJsonObject_stringOf(jResp,"motif.mediumIconUrl");
    SmallIconUrl = CkJsonObject_stringOf(jResp,"motif.smallIconUrl");
    SvgIconUrl = CkJsonObject_stringOf(jResp,"motif.svgIconUrl");
    mySubscription = CkJsonObject_stringOf(jResp,"mySubscription");
    name = CkJsonObject_stringOf(jResp,"name");
    origin = CkJsonObject_stringOf(jResp,"origin");
    AdditionalLabel = CkJsonObject_stringOf(jResp,"owner.additionalLabel");
    CommunityNickname = CkJsonObject_stringOf(jResp,"owner.communityNickname");
    CompanyName = CkJsonObject_stringOf(jResp,"owner.companyName");
    DisplayName = CkJsonObject_stringOf(jResp,"owner.displayName");
    FirstName = CkJsonObject_stringOf(jResp,"owner.firstName");
    Id = CkJsonObject_stringOf(jResp,"owner.id");
    IsActive = CkJsonObject_BoolOf(jResp,"owner.isActive");
    IsInThisCommunity = CkJsonObject_BoolOf(jResp,"owner.isInThisCommunity");
    LastName = CkJsonObject_stringOf(jResp,"owner.lastName");
    MotifColor = CkJsonObject_stringOf(jResp,"owner.motif.color");
    MotifLargeIconUrl = CkJsonObject_stringOf(jResp,"owner.motif.largeIconUrl");
    MotifMediumIconUrl = CkJsonObject_stringOf(jResp,"owner.motif.mediumIconUrl");
    MotifSmallIconUrl = CkJsonObject_stringOf(jResp,"owner.motif.smallIconUrl");
    MotifSvgIconUrl = CkJsonObject_stringOf(jResp,"owner.motif.svgIconUrl");
    MySubscription = CkJsonObject_stringOf(jResp,"owner.mySubscription");
    Name = CkJsonObject_stringOf(jResp,"owner.name");
    Message = CkJsonObject_stringOf(jResp,"owner.outOfOffice.message");
    FullEmailPhotoUrl = CkJsonObject_stringOf(jResp,"owner.photo.fullEmailPhotoUrl");
    LargePhotoUrl = CkJsonObject_stringOf(jResp,"owner.photo.largePhotoUrl");
    MediumPhotoUrl = CkJsonObject_stringOf(jResp,"owner.photo.mediumPhotoUrl");
    PhotoVersionId = CkJsonObject_stringOf(jResp,"owner.photo.photoVersionId");
    SmallPhotoUrl = CkJsonObject_stringOf(jResp,"owner.photo.smallPhotoUrl");
    StandardEmailPhotoUrl = CkJsonObject_stringOf(jResp,"owner.photo.standardEmailPhotoUrl");
    v_Url = CkJsonObject_stringOf(jResp,"owner.photo.url");
    Reputation = CkJsonObject_stringOf(jResp,"owner.reputation");
    Title = CkJsonObject_stringOf(jResp,"owner.title");
    v_Type = CkJsonObject_stringOf(jResp,"owner.type");
    ownerUrl = CkJsonObject_stringOf(jResp,"owner.url");
    UserType = CkJsonObject_stringOf(jResp,"owner.userType");
    pageCount = CkJsonObject_IntOf(jResp,"pageCount");
    parentFolder = CkJsonObject_stringOf(jResp,"parentFolder");
    pdfRenditionStatus = CkJsonObject_stringOf(jResp,"pdfRenditionStatus");
    publishStatus = CkJsonObject_stringOf(jResp,"publishStatus");
    renditionUrl = CkJsonObject_stringOf(jResp,"renditionUrl");
    renditionUrl240By180 = CkJsonObject_stringOf(jResp,"renditionUrl240By180");
    renditionUrl720By480 = CkJsonObject_stringOf(jResp,"renditionUrl720By480");
    repositoryFileId = CkJsonObject_stringOf(jResp,"repositoryFileId");
    repositoryFileUrl = CkJsonObject_stringOf(jResp,"repositoryFileUrl");
    sharingOption = CkJsonObject_stringOf(jResp,"sharingOption");
    sharingPrivacy = CkJsonObject_stringOf(jResp,"sharingPrivacy");
    sharingRole = CkJsonObject_stringOf(jResp,"sharingRole");
    systemModstamp = CkJsonObject_stringOf(jResp,"systemModstamp");
    textPreview = CkJsonObject_stringOf(jResp,"textPreview");
    thumb120By90RenditionStatus = CkJsonObject_stringOf(jResp,"thumb120By90RenditionStatus");
    thumb240By180RenditionStatus = CkJsonObject_stringOf(jResp,"thumb240By180RenditionStatus");
    thumb720By480RenditionStatus = CkJsonObject_stringOf(jResp,"thumb720By480RenditionStatus");
    title = CkJsonObject_stringOf(jResp,"title");
    CurrentPageUrl = CkJsonObject_stringOf(jResp,"topics.currentPageUrl");
    NextPageUrl = CkJsonObject_stringOf(jResp,"topics.nextPageUrl");
    v_type = CkJsonObject_stringOf(jResp,"type");
    url = CkJsonObject_stringOf(jResp,"url");
    versionNumber = CkJsonObject_stringOf(jResp,"versionNumber");
    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"topics.topics");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        i = i + 1;
    }



    CkHttp_Dispose(http);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jResp);

    }

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}"
    }
  ]
}