How to get user profile image via API
I have been working to externalize information about my users on an RTC 3.0.1 system via API. When I make a call to https://<HOST>/jazz/oslc/ I get back a nice response that includes
<rtc_cm:User rdf:resource="https://<HOST>/jazz/oslc/users/_tKYZEArvEd-_CvlJWZEkGw">
<rtc_cm:userId>aaron</rtc_cm:userId>
<dc:title>Aaron</dc:title>
<rtc_cm:emailAddress>aaron@<HOST>.com</rtc_cm:emailAddress>
<rtc_cm:photo rdf:resource="https://<HOST>/jazz/resource/content/_xD8j4BV3EeKkj9-_5VhsPg"/>
<dc:modified>2012-10-13T20:51:31.293Z</dc:modified>
<rtc_cm:modifiedBy rdf:resource="https://<HOST>/jazz/oslc/users/_KGRY4CFWEdq-WY5y7lROQw"/>
</rtc_cm:User>
When I attempt to load the photo via its rdf:resource I first get a 400 back from the server and then get stuck with an HTML response (not image) that says
You have followed a direct link to content hosted in a Jazz server. This page has been presented to ensure that a malicious website cannot use cleverly crafted content to circumvent security. If you would like to access the content, please use the link below.
On the page there is also a link to "Download content" . Clicking that link seems to set a cookie in the environment that says its ok to load that image from there on out (or its being statically cached by the browser).
The question is, is there a way to programmatically get past this html intercept response and actually retrieve the image with out a user click.
The only thing I am noticing is that it appears the reference to the link in the response message is relative ( /resource/content/_asdfasdfasd versus my link which is https://<SERVER>/jazz/osls/resource/content/_asdfasdfasdf
The other thing that may be an issue is the referrer value obviously changes on the headers. Spoofing the referrer looks to be not a good thing.
so, is it possible to load the user photo programatically? If not, what is the use case where this user information is valuable.
Accepted answer
If you are writing a Jazz Plugin (e.g. a Dashboard Viewlet), you can use the following code to access a users profile (userId is the standard Jazz User ID that is used for the login as well, e.g. ADMIN):
getProfileImage: function(userId) {
var Util = com.ibm.team.dashboard.web.util.internal.Util;
var SERVICE_PHOTO_ID = "com.ibm.team.dashboard.viewlets.service.internal.members.IMemberPhotoService";
return Util.getServiceURL(SERVICE_PHOTO_ID, null, {userId: userId});
},
2 other answers
Hi, It should be possible using the plain java client libraries. The Eclipse user editor does it. I don't know how the REST API does it, but I have (untested) code that should do it for the Plain Java Client libraries.
See https://rsjazz.wordpress.com/2013/01/08/maintaing-user-photos-with-the-plain-java-client-libraries/
Comments
Aaron Allsbrook
Oct 16 '12, 3:41 p.m.Mike Shkolnik
Sep 05 '13, 5:52 p.m.Mike Shkolnik
Sep 05 '13, 5:56 p.m.Lukas Steiger
Jul 25 '17, 3:23 a.m.