-2

I am entirely new at this. I want to know if it is possible to upload the user record profile picture via rest.

I found that the photo url is exposed via the following

/services/data/v41.0/connect/user-profiles/

I would like to understand where exactly is the photo uploaded and if there is any sample code to test if I can upload the photo via rest.

4

This is outlined in Inputs and Binary File Upload Examples and Update and Crop a User Photo.

Basically, you can use an already-uploaded file:

POST /services/data/v42.0/connect/user-profiles/005-userId/photo HTTP/1.1
<<other headers>>

{   "cropSize" : "240",
    "cropX" : "20",
    "cropY" : "20",
    "fileId" : "069D00000001IOh"
}

Or you can upload/crop a new photo:

POST /services/data/v42.0/chatter/users/me/photo HTTP/1.1
Authorization: OAuth 00DD0000000Jhd2!AQIAQC.lh4qTQcBhOPm4TZom5IaOOZLVPVK4wI_rPYJvmE8r2VW8XA.
OZ7S29JEM_7Ctq1lst2dzoV.owisJc0KacUbDxyae
User-Agent: Jakarta Commons-HttpClient/3.0.1
Host: ***instance_name***
Content-Length: 543
Content-Type: multipart/form-data; boundary=a7V4kRcFA8E79pivMuV2tukQ85cmNKeoEgJgq
Accept: application/json

--a7V4kRcFA8E79pivMuV2tukQ85cmNKeoEgJgq
Content-Type: application/json; charset=UTF-8
Content-Disposition: form-data; name="json"

{
   "cropX" : "0",
   "cropY" : "0",
   "cropSize" : "200"
}

--a7V4kRcFA8E79pivMuV2tukQ85cmNKeoEgJgq
Content-Disposition: form-data; name="fileUpload"; filename="myPhoto.jpg"
Content-Type: application/octet-stream; charset=ISO-8859-1

...contents of myPhoto.jpg...

--a7V4kRcFA8E79pivMuV2tukQ85cmNKeoEgJgq--

Please read the attached documentation; this only outlines the bare minimum that you'd need to know.

  • Hi @sfdcfox, I get an error saying The requested resource does not exist when I use API version 42.0. If I use 34.0 I don't get this message, but rather The request API is not available to portal users. You may need to specify a community for portal user access. Do you think the first error might be caused by the same permission error as in version 34? – Folkert Aug 31 '18 at 12:19
  • @Folkert The portal user API has a different endpoint, I think.You might want to ask a new question with those details and what you've tried so far. I really only have experience with internal users, not portal users, so it's likely someone else would know more than I. – sfdcfox Aug 31 '18 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.