Loading TOC...

POST /v1/config/namespaces

Summary

[DEPRECATED: Use PUT /manage/v2/servers/{id|name}/properties instead.]

Create or append to namespace bindings that can be used in subsequent query operations.

URL Parameters
format? You can use this parameter as a fallback to the request Content-type header. The Content-type header takes precedence over format in most cases; for details, see Controlling Input and Output Content Type in the REST Application Developer's Guide. Accepted values: json or xml.
Request Headers
Content-Type? The MIME type of the data in the request body, either application/xml or application/json.

Response

Upon success, MarkLogic Server responds with a status 201 (Content Created). MarkLogic Server responds with a status 400 (Bad Request) if the request contains a bad binding or attempts to replace an existing binding with a new value.

Required Privileges

This operation requires the rest-admin role, or the following privileges:

http://marklogic.com/xdmp/privileges/rest-admin

http://marklogic.com/xdmp/privileges/rest-writer

http://marklogic.com/xdmp/privileges/rest-reader

Usage Notes

For details, see Using Namespace Bindings in the REST Application Developer's Guide.

This method appends to existing namespace bindings. To replace a binding, use the PUT method.

If a binding already exists for the prefix and this request does not bind the prefix to the same namespace URI, MarkLogic server responds with status 400 (Bad Request). To change the namespace associated with prefix, use PUT /v1/config/namespaces/{prefix}.

The request body must have the following format when sending XML:

  <rapi:namespace-bindings xmlns="http://marklogic.com/rest-api">
    <rapi:prefix>the-prefix</rapi:prefix>
    <rapi:uri>the-uri</rapi:uri>
  </rapi:namespace-bindings>
    

The request body must have the following format when sending JSON:

  {"namespace-bindings": [
    {"prefix" : "the-prefix", "uri" : "the-uri" },
    ...
  ]}
    

Example

$ cat ns-xml
<namespace-bindings xmlns="http://marklogic.com/rest-api">
  <namespace>
    <prefix>bill</prefix>
    <uri>http://marklogic.com/examples/shakespeare</uri>
  </namespace>
</namespace-bindings>

$ curl --anyauth --user user:password -X POST -d@'./ns-xml' -i \
    -H "Content-type: application/xml" \
    http://localhost:8000/v1/config/namespaces

==> MarkLogic Server creates or appends the namespace binding between
    the prefix "bill" and the namespace URI 
    "http://marklogic.com/examples/shakespeare. MarkLogic Server
    returns the following headers:

Server: MarkLogic
Content-Type: text/xml; charset=UTF-8
Content-Length: 211
Connection: close

HTTP/1.1 201 Created
Location:
Server: MarkLogic
Content-Length: 0
Connection: close
  

Example

$ cat ns-json
{ "namespace-bindings": [
  {
    "prefix": "will",
    "uri": "http://marklogic.com/examples/shakespeare"
  }
] }

$ curl --anyauth --user user:password -X POST -d@'./ns-json' -i \
    -H "Content-type: application/json" \
    http://localhost:8000/v1/config/namespaces

==> MarkLogic Server creates or appends the namespace binding between
    the prefix "will" and the namespace URI 
    "http://marklogic.com/examples/shakespeare. MarkLogic Server
    returns the following headers.

Server: MarkLogic
Content-Type: text/xml; charset=UTF-8
Content-Length: 211
Connection: close

HTTP/1.1 201 Created
Location:
Server: MarkLogic
Content-Length: 0
Connection: close
  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.