I wonder how the file is encoded.  How did you create pie.txt? Seems some funny 
whitespace char up front perhaps?  Also, what version of MarkLogic do you have?



Eric



Eric Bloch
Director, Community
MarkLogic Corporation

desk +1 650 655 2390 | mobile +1 650 339 0376
email  eric.bl...@marklogic.com<mailto:eric.bl...@marklogic.com>
web    developer.marklogic.com<http://developer.marklogic.com>
twitter @eedeebee

On Feb 4, 2013, at 5:27 PM, Thomson E McKelvey 
<tmckelv...@csc.com<mailto:tmckelv...@csc.com>> wrote:

Hi Charles,

I tried renaming my file name to "pie.json" and also "pie" (with no
extension), and that didn't help.  I assume your suggestion about a header
was specifically to use an additional curl argument, so that the command
would be something like:

curl -X PUT --anyauth --user admin:admin \
-Hcontent-type:application/json -d@pie \
'http://localhost:8005/v1/documents?uri=/example/recipe&format=json'

But this didn't help, either.

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<mailto:tmckelv...@csc.com> | 
www.csc.com<http://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.



From: Charles Greer <cgr...@marklogic.com<mailto:cgr...@marklogic.com>>
To: general@developer.marklogic.com<mailto:general@developer.marklogic.com>
Date: 02/04/2013 04:58 PM
Subject: Re: [MarkLogic Dev General] REST API: Error attempting to
           insert new JSON document
Sent by: general-boun...@developer.marklogic.com



Hi Thomson,

I'm wondering if the 'txt' extension is being used over-eagerly. This
looks like a bug and I'll see if I can reproduce it.  In the meantime,
try adding a content-type header to see if that makes any difference.
It shouldn't, but it might move you forward.

-Hcontent-type:application/json

Charles


On 02/04/2013 03:54 PM, Thomson E McKelvey wrote:
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

--
Charles Greer
Senior Engineer
MarkLogic Corporation
charles.gr...@marklogic.com
Phone: +1 707 408 3277
www.marklogic.com

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


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

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

Reply via email to