Profile Photos
Overview
Users' profile photos can be updated programmatically through a series of API calls that create a location to upload a file, upload data to that file in binary format, and then associate that file to a user as a profile photo.
Prerequisites
In order to add a profile photo for the currently authenticated user, an active session must be established.
To change the profile photo of any user other than the authenticated one, the active user must have administrative permissions in the digital workplace.
For details on recommended file types and sizes for profile photos, see the Customer Care article on Updating your profile photo.
How to
To add or update a profile photo, there are three separate endpoints involved:
- POST to create an entry where the file upload will be stored
- PATCH to upload the file's content to the created entry
- POST to attach the uploaded file to a user profile
Endpoints
POST - Create an Upload Entry
.api2/api/v1/communities/{communityKey}/attachments
This will create an upload entry in your digital workspace, to which content can be uploaded with the PATCH call outlined next.
The response returns a location value in the headers, which contains the Attachment Key. The attachment key is a 10 character code which will be used to refer to the entry in subsequent calls.
Path Variables:
communityKey (Required) - Integer
The community key for the digital workplace.
Body:
ContentLength (Required) - Integer
The size in bytes of the content being uploaded.
ContentType (Required)
The MimeType of the content being uploaded.
Name (Required) - String
The filename of the upload.
PATCH - Upload file to an attachment entry
/.api2/api/v1/communities/{communityKey}/attachments/uploads/{attachmentKey}
If a content range is specified, the binary file in the body of the call will be appended on any existing data in the attachment entry. This can be used to upload a file from start to finish, or resume an incomplete upload.
To perform a complete file upload, the content range must start at 0, and must match the size of the file in the body of the request.
Headers:
Content-Range (Required) - Content range
The content range of the file being upladed, in bytes.
Content-Length (Required) - Integer
The size of the file being uploaded, in bytes.
Content-Type (Required) - MIME Type
The file type of the image being uploaded. Accepts: image/jpg, image/png, image/gif
Path Variables:
communityKey (Required) - Integer
The community key for the digital workplace.
attachmentKey (Required) - String
The location code of the destination upload entry, returned by the previous endpoint.
Body:
The binary file to be uploaded.
POST - Associate an attachment to a user profile
/.api2/api/v1/communities/{communityKey}/attachments/{attachmentKey}/association/{objectId}?type=ProfilePhoto
Params:
Type (Required) - String
For a profile photo upload, this value should always be "ProfilePhoto"
Path Variables:
communityKey (Required) - Integer
The community key for the digital workplace.
attachmentKey (Required) - String
The location code of the upload entry, returned by the intial endpoint.
objectId (Required) - GUID
The object ID of the user account to associate the profile photo.
- 438 views
- 0 previews
- 1 version
- 0 comments
- 1 follower
- Posted By:
- Kayleigh LeBlanc
- June 29, 2021
- Versions:
- v.1
0 Comments