3

I'm trying to get a user's default profile photo using the chatter api. My company's admin, created a custom image that will show up if the user hasn't uploaded their own image.

I've been reading https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_responses_pictures.htm the documentation for the smallPhotoUrl property (which is the url i'm going for) says the following: If the user hasn’t uploaded a photo and the request header included X-Connect-Theme: Salesforce1, this URL points to a default photo based on a theme that the admin selected for the org.

The problem is, I'm not seeing the theme photo, I only see the "Salesforce Classic" default profile photo. This is how i'm including the header for my request even though adding the header to the default headers is not the best way of doing it

HttpClient.DefaultRequestHeaders.Add("X-Connect-Theme","Salesforce1");

The response is a json object and the property that i'm interested in is smallPhotoUrl

"photo": {
  "fullEmailPhotoUrl": "https://myOrg.com/img/userprofile/default_profile_200_v2.png?fromEmail=1",
  "largePhotoUrl": "https://myOrg.com/profilephoto/005/F",
  "mediumPhotoUrl": "https://myOrg.com/profilephoto/005/M",
  "photoVersionId": null,
  "smallPhotoUrl": "https://myOrg.com/profilephoto/005/T",
  "standardEmailPhotoUrl": 
  "https://myOrg.com/img/userprofile/default_profile_45_v2.png?fromEmail=1",
  "url": "/services/data/v41.0/connect/user-profiles/0052F000000vZn8QAE/photo"
},

I don't understand why the profile photo is returning as the default salesforce classic photo instead of the theme photo.

0

It turns out that adding the header "X-Connect-Theme", "Salesforce1" is only available on api version 42. I was using version 41. When using version 42 of the api, the result is as expected.

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.