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

Reply via email to