Bad Request error when adding a link
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
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
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.
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.
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
Request Method : PUT
"Content-Type","application/x-oslc-cm-change-request+json"
"Accept","application/json"
{
"rtc_cm:com.ibm.team.workitem.linktype.relatedartifact.relatedArtifact":
{
"rdf:resource":"<Link>",
"oslc_cm:label":"<Label_Value>"
}
}
Cheers,
Arun