List Cosmos Document API

We can use Document APIs to manage document in Cosmos DB collection

List Document

Authorization behaviour for all the calls will be similar but we have to change verb as per our need, so we have to update Dataweave and HTTP request call to Azure.

Mule flow will look like this



%dw 2.0
import java!cosmosdb::GenerateCosmosDBAuthToken
output application/java
var verb = "GET"
var resourceType = "docs" 
var resourceId = "dbs/hr/colls/employee"
var key = "0SZd1Zs3hySH915hKBTQCbewWnzIEI4S2YK8yHDaRwMrnzrZSwaa0hHy8IW21x4qbsQoswWIh3FW8TOd0fpSYw=="
var keyType = "master"
var tokenVersion = "1.0"		 
var serverDateTime = GenerateCosmosDBAuthToken::getServerTime() as String
	serverDateTime: serverDateTime,
	authKey: GenerateCosmosDBAuthToken::generate(verb, resourceType, resourceId, key, keyType, tokenVersion, serverDateTime)

Please change the resource id and key as per your Azure details


HTTP request

<http:request method="GET" doc:name="Cosmos DB API for SQL insert" doc:id="fb1b2aa9-39f4-4fec-ba42-99b30b9534e3" config-ref="HTTP_Request_configuration" path="dbs/hr/colls/employee/docs" >
		<http:headers ><![CDATA[#[output application/java
				"Accept" : "application/json",
				"x-ms-version" : "2016-07-11",
				"x-ms-max-item-count": 10,  
				"x-ms-documentdb-query-enablecrosspartition": "False",  
				"Authorization" : vars.cosmosHeader.authKey,
				"x-ms-date" : vars.cosmosHeader.serverDateTime,
				"Content-Type" : "application/json"

Please see the path and different HTTP header we are passing in HTTP request call, please change the same as per your need


Test it through SOAP UI


Documents in Azure


Sample application – cosmos-document-list

Sample SOAP UI project – Cosmos-db-document-list-soapui-project

Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.

Share this:
Notify of
Inline Feedbacks
View all comments