title: Unable to update an item in CosmosDB using the replace method with JavaScript
body: <p>I am trying to create a basic REST API using Azure functions and the cosmosDB client for JavaScript. I have been successful with all the actions except the UPDATE. The cosmosDB client uses <code>conainter.item(id,category).replace(newObject)</code> I am unable to get the container.item().replace method to work. When I test the function in the portal or using Postman, I get a 500 error and in the portal, I get the error: <code>Result: Failure Exception: Error: invalid input: input is not string Stack: Error: invalid input: input is not string at trimSlashFromLeftAndRight</code>.</p>
  <pre><code>Example of my basic document/item properties
  
  {
    id:002,
    project:&quot;Skip rope&quot;,
    category:&quot;task&quot;,
    completed: false
  }
  
  const config = require(&quot;../sharedCode/config&quot;);
  const { CosmosClient } = require(&quot;@azure/cosmos&quot;);
  
  module.exports = async function (context, req) {
    const endpoint = config.endpoint;
    const key = config.key;
    const client = new CosmosClient({ endpoint, key });
  
    const database = client.database(config.databaseId);
    const container = database.container(config.containerId);
  
    const theId = req.params.id;
  
    // I am retrieving the document/item that I want to update
    const { resource: docToUpdate } = await container.item(theId).read();
  
    // I am pulling the id and category properties from the retrieved document/item
    // they are used as part of the replace method
    const { id, category } = docToUpdate;
  
    // I am updating the project property of the docToUpdate document/item
    docToUpdate.project = &quot;Go fly a kite&quot;;
  
    // I am replacing the item referred to with the ID with the updated docToUpdate object
    const { resource: updatedItem } = await container
      .item(id, category)
      .replace(docToUpdate);
  
    const responseMessage = {
      status: 200,
      message: res.message,
      data: updatedItem,
    };
  
    context.res = {
      // status: 200, /* Defaults to 200 */
      body: responseMessage,
    };
  </code></pre>
  <p>};</p>
  <p>I Googled the heck out of this and been through the Microsoft Azure CosmosDB documents from top-to-bottom, but I can't figure out how to get this to work.  I can get the other CRUD operations to work based on the examples Microsoft docs provide, but not this. Any help would be greatly appreciated.</p>