Reputation: 1179
I have a custom rest end point (POST) and pass some key values pairs and in my endpoint I takes these key value pairs and create an xml document.. here is the code
let $enevelope := <document-enevelope>
<metadata>
{
let $extraProperties := xdmp:get-request-field-names()
for $x at $i in $extraProperties
let $val := xdmp:get-request-field($x)
return
if(repoLoad:isEmpty($val)) then ()
else
element {fn:normalize-space($x)} {$val}}
}
</metadata>
</document-enevelope>
let $_ := xdmp:document-insert($docEnevelopeURI, $enevelope,(xdmp:default-permissions()), ())
All this works, but when I am sending to my POST request this key/value pair
"Experiment_name":"X13-284-285-A-1516147.0-V1ß iv.po.ip.b.CSF.rat."
I get the following error Error: AppRequestTask::run: SVC-BAD: Bad CodepointIterator::_next
The request I sent is not even coming to my custom rest endpoint.. I did encode the key/value in UTF-8.. I am confused as to what is wrong.. But in query console I do the same insert with the same key/value it works..
What am I doing wrong.. ??
Upvotes: 2
Views: 76
Reputation: 1179
I was able to fix my issue by URLEncoding the parametes in UTF-8 and in my rest service in Marklogic I did the xdmp:url-decode
that fixed my issue...
My Marklogic Rest service calling in java so before calling I do URLEncoder.encode(str, "UTF-8")
and in my Marklogic service endpoint I decode the params by calling xdmp:url-decode
Upvotes: 3