Last active
August 18, 2023 11:24
-
-
Save VernonGrant/299fe04775310ccf51fd5e37ed76d8db to your computer and use it in GitHub Desktop.
Root issue example, updating multiple block states.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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