Hi, Actually, I made a mistake in the Content-Type of the overall request, I used "multipart/related" instead of "multipart/mixed" as mentioned in the doc. But when I fix it, I get a 500 with the following error message:
XDMP-AS: (err:XPTY0004) $meta-type as xs:string -- Invalid coercion: () as xs:string . See the MarkLogic server error log for further detail. It seems it all goes down to $content-type being the empty sequence in the following call in document-model-update.xqy (in ML 9.0-1.1): let $document-next := if ($part-type ne "document-metadata") then () else docmodupd:parse-metadata-map($curr-uri,$content-type,$body) But then, it is beyond my knowledge... Regards, -- Florent Georges H2O Consulting http://h2o.consulting/ On 30 July 2017 at 11:41, Florent Georges wrote: > Hi, > > I am trying to use the POST /v1/documents endpoint on 8000 to insert > several documents at once. From the chapter "Reading and Writing Multiple > Documents" in the REST Guide, in section "Specifying an Explicit Document > URI" [1], the following pseudo header in each part should be enough to set > the URI for each document: > > Content-Disposition: attachment;filename=/your/uri > > But I get a 400 with the message: "REST-REQUIREDPARAM: (err:FOER0000) > Required parameter: missing required extension parameter". > > Any idea why? > > [1]https://docs.marklogic.com/guide/rest-dev/bulk#id_84006 > > Below a complete repro that can be played in QConsole (and later an > example using PUT instead, which does work): > > 'use strict'; > > const rn = '\r\n'; > const bnd = '.ml.rockzzz.'; > var body = rn; > > // first part > body += '--' + bnd + rn; > body += 'Content-Type: application/json' + rn; > body += 'Content-Disposition: attachment; filename="/test/multi-one.json"' > + rn; > body += rn; > body += JSON.stringify({ hello: 'one!' }); > body += rn; > > // second part > body += '--' + bnd + rn; > body += 'Content-Type: application/json' + rn; > body += 'Content-Disposition: attachment; filename="/test/multi-two.json"' > + rn; > body += rn; > body += JSON.stringify({ hello: 'two!' }); > body += rn; > > // after the last part > body += '--' + bnd + '--' + rn; > > xdmp.httpPost( > 'http://localhost:8000/v1/documents', { > authentication : { > method : 'digest', > username : 'admin', > password : 'admin' > }, > headers: { > "Content-type": 'multipart/related; boundary=' + bnd, > Accept: "application/json" > }, > data: body > }); > > Here is the example using PUT, and indeed working fine: > > 'use strict'; > > xdmp.httpPut( > 'http://localhost:8000/v1/documents?uri=/test/single.json', { > authentication : { > method : 'digest', > username : 'admin', > password : 'admin' > }, > headers: { > "Content-type": 'application/json', > Accept: "application/json" > }, > data: JSON.stringify({ hello: 'world!' }) > }); > > Any idea what I did wrong? > > Regards, > > -- > Florent Georges > H2O Consulting > http://h2o.consulting/ > > >
_______________________________________________ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general