I am writing a Cosmos DB post-trigger (NOT the Azure Function Trigger kind but the in-server JS one). In this trigger, I need to access the etag header generated in the response. The trigger works fine except when I add the following code :
// Retrieve item's new etag from the response
var newETag = __.response.getValue("etag");
This code causes the request to fail with the following exception : "Unable to get property 'value' of undefined or null reference at getValueInternal". I checked that the response is not null and that the getValue
function exists and in fact the exception is thrown from within the getValue
function because the property for etag does not exist.
The doc (found here) however states that:
getValue(key) → {string} Gets a specified response header value.
And other doc (found here) also states that:
The following response headers are common to all responses from the SQL API: ... etag (The etag header [...] has the same value as the _etag property in the response body.)...
Now I also DID confirm that I could indeed access the etag from the __.response.getBody()
but I cannot rely on that option because my requests are made with the EnableContentResponseOnWrite = false
option in which case the response body is null.
Can someone help me figure out what I am missing or doing wrong here ?