I'm having a problem doing simple REST API operations using the curl
utility.

Using the simplest example shown here, everything works as expected:
   $ curl -X PUT --anyauth --user admin:admin
'http://localhost:8005/v1/documents?uri=/example/recipe&format=json' \
   > -d'{"recipe":"Apple Pie", "fromScratch":true, "ingredients":"The
Universe"}'

This adds a document into my database with URI /example/recipe.  I can use
the query console to find this document and inspect its contents, as shown
here:
   <?xml version="1.0" encoding="UTF-8"?>
   <json type="object" xmlns="http://marklogic.com/xdmp/json/basic";>
     <recipe type="string">Apple Pie</recipe>
     <fromScratch type="boolean">true</fromScratch>
     <ingredients type="string">The Universe</ingredients>
   </json>

Next, I'm trying to do the same operation, except I don't want to type the
document contents into the curl command (soon the documents will be too
long for that).  Instead, I want to tell curl to read the document data
contents out of a file.  My new curl command is this:
   $ curl -X PUT --anyauth --user admin:admin
'http://localhost:8005/v1/documents?uri=/example/recipe&format=json' \
   > -d...@pie.txt
And the file pie.txt contains this:
   {"recipe":"Apple pie", "fromScratch":true, "ingredients":"The Universe"}

When I execute this curl command, I get the following error:
<rapi:error xmlns:rapi="http://marklogic.com/rest-api
"><rapi:status-code>500</rapi:status-code><rapi:status>INTERNAL
ERROR</rapi:status><rapi:message-code>XDMP-JSONCP</rapi:message-code><rapi:message>XDMP-JSONCP:
 xdmp:from-json("&amp;#xfeff;{&amp;quot;recipe&amp;quot;:&amp;quot;Apple
pie&amp;quot;, &amp;quot;fromScr...") -- Unexpected codepoint: 65279 on
line 1.  See the MarkLogic server error log for further
detail.</rapi:message></rapi:error>

Can somebody help resolve this error?

Tom McKelvey
System Programmer Analyst Leader
CSC
360 Church Street #E
San Francisco, CA 94114
CSC Healthcare Group | p: +1-415.260.2595 | m: +1-415.260.2595 | f:
+1-773.347-1979 | tmckelv...@csc.com | www.csc.com


This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit written
agreement or government initiative expressly permitting the use of e-mail
for such purpose.

_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to