It's all about the answers!

Ask a question

how-to obtain attachment data via OSLC


Scott Russell (4688) | asked Sep 07 '11, 3:14 p.m.
I'm trying to write a utility to fix-up work items after a export->import migration from one RTC system to another. But when I process attachments I am unable to obtain the actual attachment data (re: <rtc_cm> ) via the obtained rdf:resource reference.

When I do a get on the rdf:resource URI instead of the content data, I get HTML with the text:
"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."

Anyone know what I maybe doing wrong or a way around the injected HTML?


public String getAttachmentDataByReference( TeamConcertRepository repo, WorkItemAttachment wia )
{
StringBuffer data = new StringBuffer( ">>>no data retreived<<<" );
String dataReference = wia.getContentReference();
GetMethod method = new GetMethod( dataReference );
method.addRequestHeader( "Accept", wia.getFormat() );
method.addRequestHeader( "Content-type", wia.getFormat() );
method.setFollowRedirects( true );
int statusCode;
try
{
statusCode = repo.getClient().executeMethod( method );
System.err.println( "status from get is[" + statusCode + "]" );
InputStream stream = method.getResponseBodyAsStream();
.
.
.


Thanks in advance!

Comments
Mike Shkolnik commented Nov 07 '13, 6:55 p.m.

Scott, did you ever get this problem resolved? I am getting the same error.


Scott Russell commented Nov 11 '13, 10:39 a.m.

I personally never found a way but right after we did our migration I was in contact with someone who said they were able to do it. They added:

addHeader("X-Jazz-CSRF-Prevent", holyGrail);

where holyGrail = the session id in your JSESSIONID. 

One answer



permanent link
Ralph Schoon (63.4k33646) | answered Nov 08 '13, 8:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Nov 08 '13, 8:08 a.m.
As far as I am aware, there is no officially supported and documented way to download attachments with OSLC/REST. We had the situation several times in the past and the developers suggested to use the API instead as described here: https://rsjazz.wordpress.com/2012/09/21/downloading-attachments-from-work-items/

Having said that, I am aware some users have traced the communication during a download and were able to rebuild the mechanism.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.