Open aniketvsawant opened 4 years ago
All of my calls go through the MarkLogic client layer and they don't go directly against the API. I did, however, make a design choice where all "write" operations ultimately do the "bulk" document insert, which is indeed a post, even if there is only a single document. It seems to work, though, here is what the request looks like:
--> POST http://127.0.0.1:8000/v1/documents http/1.1
ML-Agent-ID: java
Authorization: Digest username="admin", realm="LOCAL", nonce="387c1cacf1226e:VJXDk3hPoBfxQFItm4Gy1A==", uri="/v1/documents", response="754ed85bf0b7630ba86100035aaf3599", qop=auth, nc=00000009, cnonce="b5a3b8ed6fb24e49", algorithm=MD5, opaque="44dedc05aca58b70"
Content-Type: multipart/mixed; boundary=2b269540-b50e-4130-84a5-dce45c57d91e
Transfer-Encoding: chunked
Host: 127.0.0.1:8000
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/4.4.0
--2b269540-b50e-4130-84a5-dce45c57d91e
Content-Disposition: attachment; filename="/Person/875aa735-1729-42da-af70-e43e596d203f.json"; category=metadata
Content-Type: application/xml
<?xml version='1.0' encoding='utf-8'?><rapi:metadata xmlns:rapi="http://marklogic.com/rest-api" xmlns:prop="http://marklogic.com/xdmp/property"><rapi:collections><rapi:collection>Person</rapi:collection></rapi:collections></rapi:metadata>
--2b269540-b50e-4130-84a5-dce45c57d91e
Content-Disposition: attachment; filename="/Person/875aa735-1729-42da-af70-e43e596d203f.json"
Content-Type: application/json
{"id":"875aa735-1729-42da-af70-e43e596d203f","name":"Bob","age":0,"active":true,"gender":"female","occupation":"","description":"","birthtime":"2020-05-19T16:35:34.436557Z","modified":"2020-05-19T16:35:34.438560Z","rankings":[],"hobbies":[],"pets":[]}
--2b269540-b50e-4130-84a5-dce45c57d91e--
--> END POST (-1-byte body)
You can see this output in your logs by doing something similar to this:
static {
System.setProperty("com.marklogic.client.okhttp.httplogginginterceptor.level", "BODY");
}
Whether PUT or POST it should work. What exact method(s) are you calling where it is not saving to the DB?
Hi Team, I am trying to publish entity as a JSON to database but every request is processing over POST method and not PUT. Due to which document is not able to persist. Need assistance to persist the record.
Non-Working Request (Generated by your library): POST http://mlHost:mlPort/v1/documents?database=mlDb Content-Type: multipart/mixed body: {"name":"john"}
Working Request: PUT http://mlHost:mlPort/v1/documents?database=mlDb&uri=sample-uri Content-Type: application/json body: {"name":"john"}