Skip to content

Instantly share code, notes, and snippets.

@VernonGrant
Last active August 18, 2023 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VernonGrant/299fe04775310ccf51fd5e37ed76d8db to your computer and use it in GitHub Desktop.
Save VernonGrant/299fe04775310ccf51fd5e37ed76d8db to your computer and use it in GitHub Desktop.
Root issue example, updating multiple block states.
const fetch = require("node-fetch");
const url =
"https://sandbox.uk.rootplatform.com/v1/insurance/claims/claim-id-here/blocks";
// This is incorrect:
let options = {
method: "PATCH",
headers: { accept: "application/json", "content-type": "application/json" },
body: JSON.stringify({
key: "first_example_block",
type: "input.text",
newKey: "New Value",
"newKey-1": "New Value",
"newKey-2": "New Value"
})
};
// This is correct:
options = {
method: "PATCH",
headers: { accept: "application/json", "content-type": "application/json" },
body: JSON.stringify([
{
key: "first_example_block",
block_state: {
type: "input.text",
value: "New value"
}
},
{
key: "second_example_block",
block_state: {
type: "input.text",
value: "Other New value"
}
}
])
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error("error:" + err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment