It's all about the answers!

Ask a question

how to update the state in RTC by send a PUT request in URL like ?_action=XXX

Zhang Li (112) | asked May 07 '20, 6:19 a.m.
edited May 07 '20, 8:58 a.m.

 Hi All,

I try to update the ticketid state, but it response 412 always.

request by GET to get the ticketis state and filter out the ETag in the response header.
the request header is {'Content-Type': 'application/json','Accept': 'application/json'}

request by PUT and set the request header to {'If-Match': '$ETag','Content-Type': 'application/x-oslc-cm-change-request+json','Accept': 'application/x-oslc-cm-change-request+json'}
the request URL is XXX/ccm/resource/itemName/$ticketid?_action=$actionname
I have got the action name by "ccm/oslc/workflows/$projectareaid/actions/$workflow?"
and set request data to the step1's response data.

it failed and the response code in step2 is 412 always.

there are 2 question when i debuging.
1st, the ETag is different when set different response header? I don't know the rot cause and how to generate the ETag.
2nd, when request PUT in step2? the request data is necessary or not? it yes, what about the content?

here is my script written by python for debuging, Anyone has idea about it or with the same issue like me.
please give me some suggestion. Thank you verrrry much~~~

    def updateTicketState(self, ticket, action):
            print ("====================STEP1:Get Etag in response header====================")
            GURL = "%s/ccm/resource/itemName/"%(RTC_URL, ticket)
            GHEADER={'Content-Type': 'application/json','Accept': 'application/json'} #response header : 'Etag' : '"283bd563-XXX"'
            GDATA = self.sendRequest2("get",GURL,headers=GHEADER)
            GDATA = {"rtc_cm:state":{"rdf:resource":"https:\/\/\/ccm\/oslc\/workflows\/_XXX\/states\/com.XXXWorkflow\/com.XXXWorkflow.state.s4"}} #response data
            print ("====================STEP2:try to update ticket state by action====================")
            action = 'com.XXXWorkflow.action.a5' #a7=fix, a5=integrate
            PHEADER={'If-Match': '"283bd563-XXX"','Content-Type': 'application/x-oslc-cm-change-request+json','Accept': 'application/x-oslc-cm-change-request+json'}
            PURL = "%s/ccm/resource/itemName/"%(RTC_URL, ticket, action)
            resp = self.sendRequest2("put",PURL,headers=PHEADER,data=GDATA)
            return resp
        except Exception,e:
            return False

Be the first one to answer this question!

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.