creating work item encounter html tags converter issue
I using following shell script to create a work item:
Shell script:
CURL=$HOST"/oslc/contexts/_nO3roXC_EeS6vP4NWXuc2g/workitems"
curl -D - -k -b $COOKIES -o "$tmpcreatelog" -H "Content-Type: application/x-oslc-cm-change-request+json" -H "Accept: text/json" -X POST --data-binary @createpdtmp.json $CURL
createpdtmp.json file:
"dc:title": "Pricing Service Call Failure:<NS1:PricingResponse (.*)<errFlag>true</errFlag> created by RTC API auto",
And while the title value in the "createpdtmp.json" file contains character '<' and '>', the characters between '<' and '>' will be missed in the created work item's title, it will become to "Pricing Service Call Failure:<NS1:PricingResponse (.*)true" in the work item' title.
I found that if I change the '<' and '>' to html tags: '<' and '>'as following, it will work. Need I to convert all the special characters to html tags? Is there any other methods to resolve this issue instead of converting to html tags? Kindly please help to check and give some advice. Thanks!
Replace '<' and '>' with html tags '<' and '>':
"dc:title": "Pricing Service Call Failure:<NS1:PricingResponse (.*)<errFlag>true<\/errFlag> created by RTC API auto",
One answer
1. Use the HTTP request header "Content-Type: application/json". I'm not quite sure why you used the one that you have chosen.
2. Escape the double quotes and slashes in your string. In other words, you would use \" and \/.
Comments
Hello,
I changed to use the HTTP request header "Content-Type: application/json" you suggested as following:
curl -D - -k -b $COOKIES -o "$tmpcreatelog" -H "Content-Type: application/json" -H "Accept: text/json" -X POST --data-binary @createpdtmp.json $CURL
And I also escape the double quotes as following:
"dc:title": "Pricing Service Call Failure:<NS1:PricingResponse (.)<errFlag>true<\/errFlag> created by RTC API auto"
But, the characters between '<' and '>' will be missed in the created work item's title as following:
Pricing Service Call Failure:<NS1:PricingResponse (.)true created by RTC API auto
Besides, I got the one I used before in following doc: Is there any more latest doc for creating working item using restapi? Thanks!
https://jazz.net/wiki/bin/view/Main/ResourceOrientedWorkItemAPIv2#Creating_Work_Items