It's all about the answers!

Ask a question

creating work item encounter html tags converter issue


Grace Wang (254) | asked Jun 24 '16, 3:44 a.m.
edited Jun 24 '16, 4:53 a.m. by Ralph Schoon (56.6k23642)
Hello,

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:  '&lt;' and '&gt;'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 '&lt;' and '&gt;':
"dc:title": "Pricing Service Call Failure:&lt;NS1:PricingResponse (.*)&lt;errFlag&gt;true&lt;\/errFlag&gt; created by RTC API auto",



One answer



permanent link
Donald Nong (14.4k213) | answered Jun 26 '16, 8:56 p.m.
The forum may have messed up your original text so it's hard to say what is what in your post. But I will suggest the following.
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
Grace Wang commented Jun 27 '16, 2:25 a.m.

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

Your answer


Register or to post your answer.