Patch request to COSMOS DB: 404 not found

Viewed 66

Updated: Solved by Sajeetharan's suggestion! Thanks.

I'm trying to implement the api to partially update cosmos db. I got 404 not found when I tested this patch request. I tested query in cosmo's db, it's working as expected. I don't know which part is wrong.

1 Answers

You should invoke the Patch on the container as how you have done fetchAll request.

Here is a sample,

const multipleOperations: PatchOperation[] = [
  {
    op: "add",
    path: "/aka",
    value: "MeFamily"
  },
  {
    op: "replace",
    path: "/lastName",
    value: "Jose"
  },
  {
    op: "remove",
    path: "/parents"
  },
  {
    op: "set",
    path: "/address/zip",
    value: 90211
  },
  {
    op: "incr",
    path: "/address/zip",
    value: 5
  }
];
const { resource: patchSource2 } = await container.item(patchId!).patch(multipleOperations);
Related