Reputation: 1761
I am ingesting a document to marklogic using REST APi from my windows machine to a database Test
which i already created.
F:\Curl>curl --anyauth --user admin:admin -X PUT -d@"F:/REST/file.xml" -i -H "Content-type: application/xml" http://localhost:8000/Test/documents?uri=/xml/F:/REST/file.xml
But i am getting error like this :
HTTP/1.1 401 Unauthorized
Server: MarkLogic
WWW-Authenticate: Digest realm="public", qop="auth", nonce="317cc2c17ace5b3680ddb90df7d7e4d9", opaque="871eddaeecdf779c"
Content-Type: text/html; charset=utf-8
Content-Length: 209
Connection: Keep-Alive
Keep-Alive: timeout=5
HTTP/1.1 404 Not Found
Content-type: text/html; charset=UTF-8
Server: MarkLogic
Content-Length: 5763
Connection: Keep-Alive
Keep-Alive: timeout=5
<!DOCTYPE html>
<html xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema"><head><title>Error ΓÇó MarkLogic Application Services</title><meta http-equiv="X-UA-Compatible" content="IE=8"/><!-- XSLTForm dependency --><link href="/common/static/css/environment-ui.css?9.0-2" media="screen" rel="stylesheet" type="text/css"/><link href="/common/static/css/universal-header.css?9.0-2" media="screen" rel="stylesheet" type="text/css"/><script src="/common/static/js/universal-header.js?9.0-2" type="text/javascript"> </script><script>var ML = ML || {}; ML.environmentUI = {};</script><script src="/common/static/js/environment-ui.js?9.0-2" type="text/javascript"> </script><link rel="stylesheet" type="text/css" href="/common/static/css/base.css"/><link rel="stylesheet" type="text/css" href="/common/static/css/master.css"/><link rel="stylesheet" type="text/css" href="/common/yui-2.8/menu/assets/skins/sam/menu.css"
Is there any thing wrong in my curl syntax ?
Updated Curl Command :
F:\Curl>curl --digest --user admin:admin -X PUT -d@"F:/REST/rest.xml" -i -H "Content-type: application/xml" "http://localhost:8000/v1/documents?uri=/rest/file.xml"
Upvotes: 1
Views: 911
Reputation: 7770
You are using anyAuth option with Curl. This tries one authentication method (basic) and then retries again (digest) if the previous one fails(and so on and so on). I hate samples with anyAuth because people get confused about the results. It is better to know what the server is expecting and use the specific auth method.
Look Closely at your post..
The first response was Ún-authorized
Then cUrl retried and received a 404 - not found. - AND the body response is actually a web page..
So, the issue is not authentication at all..
The URL 'http://localhost:8000/Test/documents?uri=/xml/F:/REST/file.xml' simply seems to not exist. I've never heard of the endpoint call Test/documents on the AppServices (8000) server.
Furthermore, for added safety, I would suggest wrapping your URL in double quotes to protect any special characters that may get mangled on the command line.
Upvotes: 3