0 votes
1.2k views
in REST API by

1 Answer

0 votes
by (30.6k points)

The classic setData actions take the variables as a JSON object in the params query parameter; complex variables are nested JSON - the whole object is replaced with what you send, so include every field you want to keep:

# task data (the task's variables)
PUT /rest/bpm/wle/v1/task/2078.456?action=setData&params={"order":{"number":"ORD-42","customer":{"id":"c1","name":"Ana"},"lines":[{"item":"A","qty":2},{"item":"B","qty":1}]},"comment":"updated"}&parts=data
BPMCSRFToken: <token>

# process instance variables (same JSON shape, one entry per variable name)
PUT /rest/bpm/wle/v1/process/2072.123/variables
Content-Type: application/json
{ "order": { "number": "ORD-42", "customer": { "id": "c1", "name": "Ana" }, "lines": [ { "item": "A", "qty": 2 } ] } }

Rules that avoid the usual errors:

  • URL-encode the params value (encodeURIComponent(JSON.stringify(obj))); very large objects exceed URL limits - use the process variables resource with a body, or a service flow.
  • Field names must match the business object definition exactly (case-sensitive); unknown fields are ignored, missing fields become null / default - read the current data first (GET .../task/{id}?parts=data), modify in place, send back.
  • Dates as ISO strings ("2025-06-01T10:00:00Z"), decimals as numbers, lists as arrays, business objects as objects; null clears a field.
  • The task must be in a state that allows data changes (received / claimed, not closed); process variables can be set on running instances.
// JavaScript client example (browser or Node)
var vars = JSON.parse(await (await fetch(base + "/rest/bpm/wle/v1/task/" + id + "?parts=data")).text()).data.data.variables;
vars.order.customer.name = "Ana Perez";
await fetch(base + "/rest/bpm/wle/v1/task/" + id + "?action=setData&params=" + encodeURIComponent(JSON.stringify(vars)) + "&parts=none", { method: "PUT", headers: { BPMCSRFToken: token } });

References

Related questions

0 votes
1 answer 1.9k views
0 votes
1 answer 2.1k views
0 votes
1 answer 2.5k views
0 votes
1 answer 997 views
asked May 15, 2016 in REST API by anonymous
0 votes
1 answer 2.2k views
asked May 15, 2016 in REST API by BPM Tips Admin (21.5k points)
0 votes
1 answer 1.0k views
0 votes
1 answer 2.2k views
0 votes
1 answer 765 views
0 votes
1 answer 943 views
0 votes
1 answer 574 views
0 votes
3 answers 4.7k views
0 votes
1 answer 1.6k views
0 votes
1 answer 1.9k views
0 votes
1 answer 1.6k views

723 questions

807 answers

98 comments

4.9k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...