How to define pass POST Data via a UX REST Data Broker?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2021 03:37 AM
I am trying to call a POST-based REST API via UX REST Data Broker from UI Builder.
I have managed to get a POST call working with no data
called in UI Builder via
api.data.approve_task.execute({
taskId: api.context.props.taskId
});
However I'm not clear on how to pass POST data into this via the `execute` method. The UI Builder API Documentation (execute) only indicates how to do this for URL parameters, but only specifies this for a simple operation with no Data.
I have tried:
1) adding as a "dataParam" (as used in createHTTPEffect)
api.data.approve_task.execute({
taskId: api.context.props.taskId
dataParam: {
comment: "my comment"
}
});
> this results in "no data" in REST client script i.e. the data isn't passed through
2) Looks like I can "hard-code" a "Request Body" in the Data Broker definition
> which get through to the REST client script - but isn't what I'm after
3) defined "data" as a parameter and tried to refer to it as
> but that results in "com.glide.rest.util.RESTRuntimeException: The payload is not valid JSON." in the logs
Any ideas on how to pass the data from client, though the Data Broker and into REST endpoint?
I have a follow on question - "if you execute the data resource, from UI Builder, how do you get access to the return data?"
"execute" doesn't return a Promise, nor does it seem to make a blocked call in the script - as logging the data via "api.data.approve_task.output" returns undefined - even though I see the data returned in Developer Tools (albeit base64 encoded)
- Labels:
-
Now Experience UI Framework
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2021 07:42 PM
Below is my request body.
{short_description: "{{short_description}}", caller_id: "{{caller_id}}"}