Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Req
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Checksum
string ls_ContentHubRepository
string ls_ContentModifiedDate
integer li_ContentSize
string ls_ContentUrl
string ls_CreatedDate
string ls_Description
string ls_DownloadUrl
string ls_ExternalDocumentUrl
string ls_ExternalFilePermissionInformation
string ls_FileAsset
string ls_FileExtension
string ls_FileType
string ls_FlashRenditionStatus
string ls_Id
integer li_IsFileAsset
integer li_IsInMyFileSync
integer li_IsMajorVersion
string ls_MimeType
string ls_ModerationFlags
string ls_ModifiedDate
string ls_Color
string ls_LargeIconUrl
string ls_MediumIconUrl
string ls_SmallIconUrl
string ls_SvgIconUrl
string ls_MySubscription
string ls_Name
string ls_Origin
string ls_AdditionalLabel
string ls_CommunityNickname
string ls_CompanyName
string ls_DisplayName
string ls_FirstName
string ls_Id
integer li_IsActive
integer li_IsInThisCommunity
string ls_LastName
string ls_MotifColor
string ls_MotifLargeIconUrl
string ls_MotifMediumIconUrl
string ls_MotifSmallIconUrl
string ls_MotifSvgIconUrl
string ls_MySubscription
string ls_Name
string ls_Message
string ls_FullEmailPhotoUrl
string ls_LargePhotoUrl
string ls_MediumPhotoUrl
string ls_PhotoVersionId
string ls_SmallPhotoUrl
string ls_StandardEmailPhotoUrl
string ls_V_Url
string ls_Reputation
string ls_Title
string ls_V_Type
string ls_OwnerUrl
string ls_UserType
integer li_PageCount
string ls_ParentFolder
string ls_PdfRenditionStatus
string ls_PublishStatus
string ls_RenditionUrl
string ls_RenditionUrl240By180
string ls_RenditionUrl720By480
string ls_RepositoryFileId
string ls_RepositoryFileUrl
string ls_SharingOption
string ls_SharingPrivacy
string ls_SharingRole
string ls_SystemModstamp
string ls_TextPreview
string ls_Thumb120By90RenditionStatus
string ls_Thumb240By180RenditionStatus
string ls_Thumb720By480RenditionStatus
string ls_Title
string ls_CurrentPageUrl
string ls_NextPageUrl
string ls_V_type
string ls_Url
string ls_VersionNumber
integer i
integer li_Count_i
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Req = create oleobject
// Use "Chilkat_9_5_0.HttpRequest" for versions of Chilkat < 10.0.0
li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest")
loo_Req.HttpVerb = "POST"
loo_Req.Path = "/services/data/v{{version}}/connect/files/users/me"
loo_Req.ContentType = "multipart/form-data"
li_Success = loo_Req.AddFileForUpload2("fileData"," path to file","application/octet-stream")
loo_Req.AddHeader("Authorization","Bearer <access_token>")
loo_Req.AddHeader("Expect","100-continue")
loo_Resp = loo_Http.SynchronousRequest("domain.com",443,1,loo_Req)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Req
return
end if
loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Resp.GetBodySb(loo_SbResponseBody)
loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Resp.Header
Write-Debug "Failed."
destroy loo_Resp
destroy loo_Http
destroy loo_Req
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
destroy loo_Resp
// 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
ls_Checksum = loo_JResp.StringOf("checksum")
ls_ContentHubRepository = loo_JResp.StringOf("contentHubRepository")
ls_ContentModifiedDate = loo_JResp.StringOf("contentModifiedDate")
li_ContentSize = loo_JResp.IntOf("contentSize")
ls_ContentUrl = loo_JResp.StringOf("contentUrl")
ls_CreatedDate = loo_JResp.StringOf("createdDate")
ls_Description = loo_JResp.StringOf("description")
ls_DownloadUrl = loo_JResp.StringOf("downloadUrl")
ls_ExternalDocumentUrl = loo_JResp.StringOf("externalDocumentUrl")
ls_ExternalFilePermissionInformation = loo_JResp.StringOf("externalFilePermissionInformation")
ls_FileAsset = loo_JResp.StringOf("fileAsset")
ls_FileExtension = loo_JResp.StringOf("fileExtension")
ls_FileType = loo_JResp.StringOf("fileType")
ls_FlashRenditionStatus = loo_JResp.StringOf("flashRenditionStatus")
ls_Id = loo_JResp.StringOf("id")
li_IsFileAsset = loo_JResp.BoolOf("isFileAsset")
li_IsInMyFileSync = loo_JResp.BoolOf("isInMyFileSync")
li_IsMajorVersion = loo_JResp.BoolOf("isMajorVersion")
ls_MimeType = loo_JResp.StringOf("mimeType")
ls_ModerationFlags = loo_JResp.StringOf("moderationFlags")
ls_ModifiedDate = loo_JResp.StringOf("modifiedDate")
ls_Color = loo_JResp.StringOf("motif.color")
ls_LargeIconUrl = loo_JResp.StringOf("motif.largeIconUrl")
ls_MediumIconUrl = loo_JResp.StringOf("motif.mediumIconUrl")
ls_SmallIconUrl = loo_JResp.StringOf("motif.smallIconUrl")
ls_SvgIconUrl = loo_JResp.StringOf("motif.svgIconUrl")
ls_MySubscription = loo_JResp.StringOf("mySubscription")
ls_Name = loo_JResp.StringOf("name")
ls_Origin = loo_JResp.StringOf("origin")
ls_AdditionalLabel = loo_JResp.StringOf("owner.additionalLabel")
ls_CommunityNickname = loo_JResp.StringOf("owner.communityNickname")
ls_CompanyName = loo_JResp.StringOf("owner.companyName")
ls_DisplayName = loo_JResp.StringOf("owner.displayName")
ls_FirstName = loo_JResp.StringOf("owner.firstName")
ls_Id = loo_JResp.StringOf("owner.id")
li_IsActive = loo_JResp.BoolOf("owner.isActive")
li_IsInThisCommunity = loo_JResp.BoolOf("owner.isInThisCommunity")
ls_LastName = loo_JResp.StringOf("owner.lastName")
ls_MotifColor = loo_JResp.StringOf("owner.motif.color")
ls_MotifLargeIconUrl = loo_JResp.StringOf("owner.motif.largeIconUrl")
ls_MotifMediumIconUrl = loo_JResp.StringOf("owner.motif.mediumIconUrl")
ls_MotifSmallIconUrl = loo_JResp.StringOf("owner.motif.smallIconUrl")
ls_MotifSvgIconUrl = loo_JResp.StringOf("owner.motif.svgIconUrl")
ls_MySubscription = loo_JResp.StringOf("owner.mySubscription")
ls_Name = loo_JResp.StringOf("owner.name")
ls_Message = loo_JResp.StringOf("owner.outOfOffice.message")
ls_FullEmailPhotoUrl = loo_JResp.StringOf("owner.photo.fullEmailPhotoUrl")
ls_LargePhotoUrl = loo_JResp.StringOf("owner.photo.largePhotoUrl")
ls_MediumPhotoUrl = loo_JResp.StringOf("owner.photo.mediumPhotoUrl")
ls_PhotoVersionId = loo_JResp.StringOf("owner.photo.photoVersionId")
ls_SmallPhotoUrl = loo_JResp.StringOf("owner.photo.smallPhotoUrl")
ls_StandardEmailPhotoUrl = loo_JResp.StringOf("owner.photo.standardEmailPhotoUrl")
ls_V_Url = loo_JResp.StringOf("owner.photo.url")
ls_Reputation = loo_JResp.StringOf("owner.reputation")
ls_Title = loo_JResp.StringOf("owner.title")
ls_V_Type = loo_JResp.StringOf("owner.type")
ls_OwnerUrl = loo_JResp.StringOf("owner.url")
ls_UserType = loo_JResp.StringOf("owner.userType")
li_PageCount = loo_JResp.IntOf("pageCount")
ls_ParentFolder = loo_JResp.StringOf("parentFolder")
ls_PdfRenditionStatus = loo_JResp.StringOf("pdfRenditionStatus")
ls_PublishStatus = loo_JResp.StringOf("publishStatus")
ls_RenditionUrl = loo_JResp.StringOf("renditionUrl")
ls_RenditionUrl240By180 = loo_JResp.StringOf("renditionUrl240By180")
ls_RenditionUrl720By480 = loo_JResp.StringOf("renditionUrl720By480")
ls_RepositoryFileId = loo_JResp.StringOf("repositoryFileId")
ls_RepositoryFileUrl = loo_JResp.StringOf("repositoryFileUrl")
ls_SharingOption = loo_JResp.StringOf("sharingOption")
ls_SharingPrivacy = loo_JResp.StringOf("sharingPrivacy")
ls_SharingRole = loo_JResp.StringOf("sharingRole")
ls_SystemModstamp = loo_JResp.StringOf("systemModstamp")
ls_TextPreview = loo_JResp.StringOf("textPreview")
ls_Thumb120By90RenditionStatus = loo_JResp.StringOf("thumb120By90RenditionStatus")
ls_Thumb240By180RenditionStatus = loo_JResp.StringOf("thumb240By180RenditionStatus")
ls_Thumb720By480RenditionStatus = loo_JResp.StringOf("thumb720By480RenditionStatus")
ls_Title = loo_JResp.StringOf("title")
ls_CurrentPageUrl = loo_JResp.StringOf("topics.currentPageUrl")
ls_NextPageUrl = loo_JResp.StringOf("topics.nextPageUrl")
ls_V_type = loo_JResp.StringOf("type")
ls_Url = loo_JResp.StringOf("url")
ls_VersionNumber = loo_JResp.StringOf("versionNumber")
i = 0
li_Count_i = loo_JResp.SizeOfArray("topics.topics")
do while i < li_Count_i
loo_JResp.I = i
i = i + 1
loop
destroy loo_Http
destroy loo_Req
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
--form 'fileData=@"/path/to/file"'
https://domain.com/services/data/v{{version}}/connect/files/users/me
Postman Collection Item JSON
{
"name": "Users Files, General",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {}
},
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "fileData",
"type": "file",
"src": [
]
}
]
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/files/users/me",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"files",
"users",
"me"
]
},
"description": "Upload a file, including references to external files, to the Files home or get information about files a user owns. These files don’t include files shared with a user, files a user follows, or general organization files.\nWhen you upload a file to the Files home, it is private and available only to the file owner.\n\nTo upload a file, send it in a multipart/form-data request. You can include the description and title of the file in the multipart/form-data request as a JSON or XML request body. You can also send the information as request parameters. For information about how to create the multipart/form-data message, see Uploading Binary Files.\nhttps://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_users_files_general.htm"
},
"response": [
{
"name": "Successful Users Files, General",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "fileData",
"type": "file",
"src": "/Users/scolladon/Downloads/1x1.png"
}
]
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/files/users/me",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"files",
"users",
"me"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Mon, 20 Nov 2023 16:28:22 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}"
}
]
}