Using the c# .Net client SDK, I am calling the ExecuteStoredProcedureAsync method as follows:
sproc_response = await client.ExecuteStoredProcedureAsync<Document>(sproc_uri, new RequestOptions { PartitionKey = new PartitionKey( my_partition_key) }, doc_to_create );
The stored procedure code is as follows:
sproc.Body = @"function( doc ) {
var collection = getContext().getCollection();
var response = getContext().getResponse();
function create_doc_callback( err, doc_created, options ) {
if(err) throw new Error('Error creating document: ' + err.message);
response.setBody( doc_created );
}
collection.createDocument( collection.getSelfLink(), doc, {}, create_doc_callback );
}";
This ALWAYS results in the following exception being thrown:
Error creating document: Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted.
Is there any documentation or example that clearly shows how to call a stored procedure using a partition key -- obviously, I am missing something!