Geert, Justin,

I found a function in the REST API code that parses the boundary identifier 
from the Accept header, and using that I was able to decode the multipart 
payload. Thanks both for your help! 

-W

> On May 17, 2016, at 3:58 PM, Justin Makeig <[email protected]> 
> wrote:
> 
> Use xdmp:multipart-decode(), passing in your boundary ('93e70dee8807c5e7'). 
> (You usually specify the boundary identifier in the request Accept header.) 
> xdmp:multipart-decode() will give you a sequence of document nodes, prepended 
> with a manifest of what it has decoded. It will use the content-type header 
> for each part to parse the particular part.
> 
> Justin
> 
>> On May 17, 2016, at 1:50 PM, Will Thompson <[email protected]> wrote:
>> 
>> Hi Geert,
>> 
>> I think I finally have a test that correctly sends multipart/mixed 
>> (evidently curl reserves the < character when passing a string value!), but 
>> the request body from the POST I get is binary: 
>> document{binary{"2d2d2d2d2d2d2.... When I send that to the error log, 
>> though, it somehow knows to return a string (?):
>> 
>> --------------------------93e70dee8807c5e7
>> Content-Disposition: form-data; name="name"; filename="test1.xml"
>> Content-Type: application/xml
>> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> <Document>Document 1</Document>
>> --------------------------93e70dee8807c5e7
>> Content-Disposition: form-data; name="name"; filename="test2.xml"
>> Content-Type: application/xml
>> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> <Document>Document 2</Document>
>> ...
>> 
>> This looks nearly correct, but I'm not sure what to do with this multipart 
>> payload now that I have it.
>> 
>> -W
>> 
>> 
>>> On May 17, 2016, at 1:19 PM, Geert Josten <[email protected]> 
>>> wrote:
>>> 
>>> Hi Will,
>>> 
>>> Have you tried using an HTTP client that supports sending multipart/mixed?
>>> You should also be able to use form-data. That works in a similar way, and
>>> you can test that with a HTML form with multiple file input fields. These
>>> input fields should get translated to request-fields with file names
>>> attached.
>>> 
>>> Cheers,
>>> Geert
>>> 
>>> On 5/17/16, 8:09 PM, "[email protected] on behalf of
>>> Will Thompson" <[email protected] on behalf of
>>> [email protected]> wrote:
>>> 
>>>> Is there a recommended method of posting multiple documents to a ML
>>>> endpoint in one request? Maybe this is a more general HTTP question, but
>>>> I have tried several permutations of curl options, and unfortunately the
>>>> only one that works on the ML side involves joining the documents
>>>> together into a single payload with multiple root elements:
>>>> 
>>>> curl -u user:pass -k -X POST \
>>>> -H "Content-Type: text/xml" \
>>>> -d '<Document>Document 1</Document><Document>Document 2</Document>' \
>>>> https://localhost:1234/my-endpoint
>>>> 
>>>> And in XQuery, the sequence of <Document> elements is retrieved by
>>>> xdmp:get-request-body()/node(). But this can't be right, can it?
>>>> 
>>>> -Will
>>>> _______________________________________________
>>>> General mailing list
>>>> [email protected]
>>>> Manage your subscription at:
>>>> http://developer.marklogic.com/mailman/listinfo/general
>>> 
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> Manage your subscription at: 
>>> http://developer.marklogic.com/mailman/listinfo/general
>> 
>> _______________________________________________
>> General mailing list
>> [email protected]
>> Manage your subscription at: 
>> http://developer.marklogic.com/mailman/listinfo/general
> 
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at: 
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to