Community articleReplacing a photo
Added by IBM contributorIBM on April 10, 2014
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars1 comment

To replace the image file that supplies the photo for a person's profile, send a binary image file to the web address defined in the image file link returned by the Profile's entry document.



To replace the image file that supplies the photo for a person's profile, send a binary image file to the web address defined in the image file link returned by the Profile's entry document.

You can only replace a photo if you are the profile owner or an administrator. See Authenticating requests for information about how to authenticate the request.

To replace the photo associated with a profile, complete the following steps:
1. Get the service document for the person's profile. See Retrieving the Profiles service document.
2. From the service document, get the URI for the profiles feed which is specified in the href attribute of the collection element and use it to get the profiles feed for the user.
3. In the returned feed, find the link where the rel attribute has the value "http://www.ibm.com/xmlns/prod/sn/image" .../>. Alternatively, use the URI specified in the "Request Details" table below.

<link
href="https://profiles.enterprise.example.com/profiles/photo.do?key=
b559403a-9r32-2c81-c99w-ppq8bb69442j&lastMod=1204662695516"
rel="http://www.ibm.com/xmlns/prod/sn/image"
type="image" /> 

Note: Be sure to make the new image file available to the application. For example, if you are writing a Java™ application, you might use a method that extends the EntityEnclosingMethod class to reference the file. Or, you might make the file available by adding it to a file system location that is HTTP addressable.


4. Use this link to send a PUT request to replace the image file.

A binary image file in the format indicated by the Content-Type header in the payload of the request is required. A REST client that supports a binary stream of the media file you are trying to add is also required. No ATOM xml payload needed for this operation.

Input
Method URI Description
PUT /profiles/photo.do Value of the href attribute of the <link rel="http://www.ibm.com/xmlns/prod/sn/image" .../> element in the user's profiles feed.
Name Type Optional Description
key
string No An ID generated by Profiles to identify a certain profile.
Name Type Optional Description
Content-Type
string No Indicates the format of the binary image data in the payload. Use "image/jpeg", "image/pjpeg", or "image/gif".
Output
Code Description
200
OK. Indicates that the request was received successfully.
400
Bad Request. Returned when no matching user record can be found.
Sahil Sethi commented on Mar 9, 2016

Re: Adding a photo to a profile

How to add binary image in the request payload?