How to put data bindings in JSON field of API action?

I made a server action with the ‘api action’.
Then I want to use a data binding for an ID:

However, in this example you can see it throws an error, which doesn’t allow me to save.
I need a way to ‘escape’ the data binding, I think…

I can get it working by putting the data binding in a string via quotes: "{{USING_THIS_CONTACT_ID}}"

But then I get an error back from the endpoint, as it expects an integer, not a string.

How can I use a data binding here?

Have you tried to first do a set value for your total json and refer to that in your api action?

Just tried, but I don’t see how it’s different?

Maybe I’m missing something?

I can save it if I put the type to ‘text’

So for a short moment it seems to work:

Until I click away from this step, and it becomes blank

EDIT

Got it working by doing this: {{{
“external_sales_invoice”: {
“reference”: “referencetesthere”,
“contact_id”: USING_THIS_CONTACT_ID,
“details_attributes”: [
{
“description”: “Rocking Chair”,
“price”: 129.95
}
]
}
}}}

Thanks @jellederijke !


I still hope for a solution to put in the json directly though

2 Likes

You can build the JSON dynamically and then set using {{_strJSON}}

Sorry I don’t fully understand, can you expand?

Or is this what you mean?

Yes, that’s what I mean. We’ve used it to build quite complex, custom Elastic search queries

1 Like