I figured it out. Found the answer here. First, we need to get the gids of custom_fields for a task. Then, when creating a task, specify an object for custom fields in the payload:
{
“data”: {
“name”: "Name of task,
…
…
"custom_fields: {
“12345”: “value”
“67890”: “98765”
},
“workspace”: “123”
}
Thanks for your help.