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

Question about query work item by using REST API

Hello,

I used following shell script to query work item:
curl -k  -b $COOKIES -o "$tmpquerylog" -H "Accept: application/x-oslc-cm-changerequest+json" $QURL

And following is the value for QURL:
QURL=$HOST"/oslc/contexts/_nO3roXC_EeS6vP4NWXuc2g/workitems?oslc_cm.query=oslc_cm%3AsearchTerms%3D%22*$pdtitle*%22%20and%20dc%3Atitle%3D%22*$pdtitle*%22%20and%20dc%3Atype%3D%22$pdtype%22%20and%20rtc_cm%3Astate%21%3D%22$pdstate%22&oslc_cm.properties=dc%3Atitle%2Cdc%3Aidentifier "

The confusion is that I need to convert all the special characters except english character to URL code format including the character in the value of some params, such as pdtitle.

Following script is that I used to convert them. Is there any other better methods to deal with it instead of converting? Kindly please check and give some advice, thanks!
pdtitle=`echo $PD_TITLE | sed -r -e 's/:/%3A/g' | sed -r -e 's/ /%20/g' | sed -r -e 's/"/%22/g' | sed -r -e 's/=/%3D/g' | sed -r -e 's/,/%2C/g' | sed -r -e 's/\//%2F/g' | sed -r -e 's/\\\/%5C/g' | sed -r -e 's/</%3C/g' | sed -r -e 's/>/%3E/g' | sed -r -e 's/\(/%28/g' | sed -r -e 's/\)/%29/g' | sed -r -e 's/\*/%2A/g' | sed -r -e 's/\./%2E/g' | sed -r -e 's/-/%2D/g' | sed -r -e 's/_/%5F/g'`



0 votes


Accepted answer

Permanent link
see answer 13 here
http://askubuntu.com/questions/53770/how-can-i-encode-and-decode-percent-encoded-strings-on-the-command-line

Grace Wang selected this answer as the correct answer

0 votes

Comments

Thanks! It works!

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

Question asked: Jun 27 '16, 6:26 a.m.

Question was seen: 909 times

Last updated: Jun 28 '16, 11:27 p.m.

Confirmation Cancel Confirm