How to check if a couchdb document exists (without retrieving it)? - couchdb

How can I just check if a document exists, mabye get the revision, but not make couchdb send the body of the document?
I remember I saw this explained somewhere but I cannot find it.
Edit: Iirc in the example you received only a http header with no data. The header indicated if present or not.
Edit2: Evan suggests to make a HEAD request (instead of GET). This answers my question.
CouchDB sends an ETag Header for document requests. The ETag Header is simply the document's revision in quotes.
Quoted from: http://wiki.apache.org/couchdb/HTTP_Document_API#ETags.2BAC8-Caching

Instead of performing a HTTP GET request, do a HTTP HEAD request. This will only return the headers and no content. The returned status will tell you if the object exists.

Related

Dynamics Web API BATCH POST vs PATCH (remove navigation property value)

I am attempting to Disassociate a reference a contact reference to a single-valued navigation property by setting the value to null.
This works when I call the web api directly:
PATCH https://mydynamics.crm.dynamics.com/api/data/v9.2/contacts(00000000-0000-0000-0000-000000000000)
{ "firstname": "John",
"lastname":"Doe",
"lookup1#odata.bind": null,
"lookup2#odata.bind": null,
"lookup3#odata.bind": null
}
//[...other data omitted for brevity...]
So these lookup fields, lookup 1,2, and 3 would be reset to null (The association is removed).
We run a synchronization program that calls these operations in a batch and when this runs -- using the same payload -- the lookup fields fail to reset (although if I modified firstname or lastname - those fields would update). This is a POST batch call containing just the single PATCH operation in this case but it normally contains multiple operations.
All documentation I can find states that PATCH with multiple operation should be a POST call but it didn't reset my lookups.
If I change the POST batch to a PATCH batch...then it works as expected and all fields are updated correctly including the lookups!
Why the difference between BATCH POST vs PATCH?!
Is is a bug in the API?
Is it because I only had a single operation
in the batch? Would it work for multiple requests? (I didnt try).
Does using PATCH instead of POST have any negative affect on either a
single operation or multiple operations? Suppose a DELETE operation
was also in the batch for something? Microsoft says "Use a POST
request to submit a batch operation that contains multiple requests.
A batch request can include GET requests and change sets."
Why is the
documentation lacking on this topic?
Any help is appreciated!
Read your question while searching for related CRM WEB API challenges.
The response may be a bit overdue but here's what I think applies to your case:
POST, GET, PUT, PATCH, and DELETE are HTTP request types.
When using PATCH on MS CRM you can only edit a single record.
When you want to perform multiple operations at once you use a POST request to post a whole batch of different requests. This can include multiple PATCH requests.
How to POST a batch is described quite okay here:
https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/execute-batch-operations-using-web-api

Non-standard REST pagination approach in Data Factory?

I'm trying to figure out how to work with a REST api call that is paginated. The JSON response from each page of pagination has a flag "lastPage": True or "lastPage": False to specify if you've reached the last page.
In the Data Factory REST Connector article, the pagination section mentions several supported pagination schemes:
Absolute or relative path of next page in response body or header
Query parameter for the next page in response body or header
Header value for next page in response body or header
None of these three approaches seem to describe the type of response I'm dealing with. What solution would work in this case?
Here's the documentation for the API I'm working with.
About your request, it's not supported for now.
You could post the feedback here: https://feedback.azure.com/forums/270578-data-factory
We can help you vote it up to make product team know.

Talend - How To Retrieve Response Headers From tRestClient

I'm using tRestClient to pull data from a REST API which returns data in pages of up to 200 items each. The link to the next page is provided in the response header.
How do I access the response header using tRestClient?
From what I can see, the only data returned is located in the body of the response.
Note: the same call from Postman verifies the existence of a response header labeled "Link" which contains the necessary data.
I found the answer in a post in the Talend Community
The response headers are stored in a global variable which is only actually populated when the response body is passed over to something such as a tLogRow (even if there isn't any content in the response body).
The global variable can be accessed via:
((java.util.Map<String,java.util.List<String>>)globalMap.get("tRESTClient_1_HEADERS")).get("NAME_OF_HEADER_FIELD_HERE").get(INDEX_HERE).toString();
where "NAME_OF_HEADER_FIELD_HERE" is the key (string) of the specific header you are interested in and "INDEX_HERE" is the integer index (0-based) of a specific value in the list of values associated with that particular header.
In this case we are explicitly converting the result to a string which is then used elsewhere.

Encoding is happening while sending parameter from Post request in Jmeter

I have a Post request in Jmeter in which, ViewState parameter is passing but value for that parameter is combination of alphabates, number, special characters . so while send that parameter request is encoding the special character for e.g. i have forward slash in paramter so while sending it is converting it to %2F and that leads in failing the request
Solution i have tried is:
uncheck URL Encode check box
UTF-8 in content encoding
for ViewState providing ${__urldecode('${viewState}')} value as Parameter value, which(viewState) i am fetching from previous response
used replace function in Parameter value
So what i am expecting is while sending Post request parameters should not get encoded.
Can someone please provide solution
I am assuming that you are trying to correlate the variable in the body of the subsequent request(2nd Request).
Try sending the data in "Body Data" instead of parameters. So, it is your variable i.e ${viewState} in "Body Data"
I hope view state is not in the URL.
Hope this helps.

finding content-type from wireshark

Here are the wireshark logs of 3 POST's. All posting the same data but with different content-types, resulting in different ways the data is read on the server. I'm attempt to to understand how to create POST Z.
POST X
Explicitly setting form based post
gives
POST Y
Omitted content-type
gives
POST Z ?
My app is not able to reproduce this.
gives
I'm attempting to guess what content-type in the last POST Z (notice there are no brackets), which made the post parameters appear as data ( and apparently without a data-type )
Thanks
~B
I'm attempting to guess what content-type in the last POST Z (notice there are no brackets), which made the post parameters appear as data ( and apparently without a data-type )
The content type is probably "none".
You're not obliged to send a Content-Type: header with a POST request. The HTTP 1.1 spec, RFC 2616, says in section 7.2.1 "Type":
Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body. If and only if the media type is not given by a Content-Type field, therecipient MAY attempt to guess the media type via inspection of its content and/or the name extension(s) of the URI used to identify the resource. If the media type remains unknown, the recipient SHOULD treat it as type "application/octet-stream".
It says SHOULD, not MUST, so a sender is allowed to send an entity-body without a Content-Type: header.

Resources