Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

PUT request to update work item returns response 412 despite using up to date ETag

I'm trying to update work items through the API according to https://jazz.net/wiki/bin/view/Main/ResourceOrientedWorkItemAPIv2#Update_a_Work_Item


My headers include:
'Accept' = 'application/json'
'Content-Type' = 'application/x-oslc-cm-change-request+json'

Body data is {"dc:description": "Hello World"}

I've verified that the ETag is correct by:
1. Get work item and pull ETag from header -> cbb1c290-bc00-31e0-a82b-cd783d3add31
2. Attempt to PUT an update using 'If-Match': 'cbb1c290-bc00-31e0-a82b-cd783d3add31' -> response 412: Precondition Failed: there is a later version of this item available
3. Get work item and pull ETag from header -> cbb1c290-bc00-31e0-a82b-cd783d3add31

Am I missing something? There doesn't seem to be any way the ETag could be out of date.

0 votes

Comments

You should copy literally whatever's in the ETag header into If-Match - don't modify or remove quotes even if it appears to have them. Not sure about EWM but for DOORS Next the ETag looks like it is in double quotes  ETag: "%220%22&_6CYSGZd9Ee-u9O23RJI2Og" and these must be kept when copying to the If-Match.



One answer

Permanent link

I have successfully used the ETAG to update items. E.g. see the blog series here: https://rsjazz.wordpress.com/2022/02/02/ewm-work-item-oslc-cm-api/ 

I am unable to tell what you are doing wrong, because, to be honest, your question does not contain a lot of information and I should not spend my time comprehending it. As far as I could tell, your request might fail because of funny quote characters, incorrect Accept or Content Type headers, or a multitude of other potential issues. There is no information in the question that would allow to tell. 

0 votes

Comments

My headers include 'Accept' = 'application/json' and 'Content-Type' = 'application/x-oslc-cm-change-request+json'.


For the ETag I've tried cbb1c290-bc00-31e0-a82b-cd783d3add31, "cbb1c290-bc00-31e0-a82b-cd783d3add31", and /"cbb1c290-bc00-31e0-a82b-cd783d3add31/"



The If-Match has to be "e204f6e9-355a-31f5-b818-694b14a35028". That API is ancient, I would suggest to rather use OSLC CM https://www.oasis-open.org/standard/oslc-cm-v3-0-ps01/ .
I have not found a pair of Content-Type and Accept headers that successfully worked for me.

Accept: application/rdf+xml OSLC-Core-Version: 2.0


Accept: application/rdf+xml OSLC-Core-Version: 2.0 Content-Type: application/rdf+xml  If-Match: "5d01628b-3608-3a2c-ac05-fa548fed3656" 

With a payload modified from the GET worked for me.

The older API creates different error messages with different Accept and Content-Type values, including the error about later versions, even if there is not an older version.

Does the new API only support rdf+xml? I've been trying it with ld+json and it returns 406 regardless of accept or content type headers.

I provided all the headers I used in my comments.

This is the specification: https://docs.oasis-open-projects.org/oslc-op/core/v3.0/oslc-core.html


OSLC Services MUST support at least one RDF resource serialization format, and SHOULD support as many serialization formats as possible through content negotiation. [CORE-6]

OSLC Services SHOULD provide and accept RDF documents in Turtle format (identified by the MIME-type 'text/turtle') and in JSON-LD format (identified by the MIME-type 'application/ld+json') representations for each OSLC resource for compatibility with LDP 1.0. [CORE-7]

OSLC Services SHOULD provide and accept RDF/XML representations for each OSLC resource to preserve compatibility with [OSLCCore2]. [CORE-8]

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,948

Question asked: Dec 12 '24, 4:28 p.m.

Question was seen: 275 times

Last updated: Dec 16 '24, 10:08 a.m.

Confirmation Cancel Confirm