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'`
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'`