It's all about the answers!

Ask a question

Bad Request error when adding a link


Eric Bordeau (27632) | asked Aug 03 '09, 9:07 a.m.
JAZZ DEVELOPER
I'm trying to add a link to an existing work item using REST/OAuth. I get the work item, find its rtc_cm:com.ibm.team.workitem.linktype.relatedartifact.relatedArtifact element and get the oslc_cm:collref attribute. From here, I've tried 2 different approaches. First, I tried following the instructions here: https://jazz.net/wiki/bin/view/Main/ResourceOrientedWorkItemAPIv2#Adding_Links_to_a_Work_Item. That says to POST a new link entry to the collection URL. Second, I tried getting the collection, adding a new element and doing a PUT on the collection URL. Both of these ended up with a Bad Request error.

Is there any way to figure out what's wrong with my request? I have no idea where to go from here.

Thanks,
Eric

2 answers



permanent link
Eric Bordeau (27632) | answered Aug 03 '09, 12:22 p.m.
JAZZ DEVELOPER
More specific info:

1) I set up OAuth and have a valid token.
2) I have a URL for a work item: https://localhost:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/1
3) I GET that work item
4) I find the rtc_cm:com.ibm.team.workitem.linktype.relatedartifact.relatedArtifact element
5) I get the oslc_cm:collref attribute
6) I POST to the collref URL using the following:
Content-Type: application/x-oslc-cm-change-request+xml
Accept: application/xml
content: <rtc_cm:Reference rdf:resource="someURL" oslc_cm:label="foo" />

I have also tried getting the collection, modifying it and doing a PUT with the whole collection.

permanent link
Arun Batra (14612225) | answered Jan 18 '12, 8:22 a.m.
I understand the topic is quite old, but for someone who comes across this link searching for a solution, a link can be added using oslc directly using a request of the following type.

Request URL : https://yourserveraddress/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/<workItemId>
Request Method : PUT

Headers :
"Content-Type","application/x-oslc-cm-change-request+json"
"Accept","application/json"

Request Body:
{
"rtc_cm:com.ibm.team.workitem.linktype.relatedartifact.relatedArtifact":
{
"rdf:resource":"<Link>",
"oslc_cm:label":"<Label_Value>"
}
}

Cheers,
Arun

Your answer


Register or to post your answer.