0

Based on the API documentation here, I know I can make an HTTP call to Foundry to apply an action: https://www.palantir.com/docs/foundry/api/ontology-resources/actions/apply-action/. I also know that action can be function-backed: https://chapter.palantirfoundry.com/docs/foundry/action-types/function-actions-getting-started/.

My question is, can you have the function used to define an action return some value (say the ID to a created object), and have that value be returned in the API call response body?

I noticed that the return type of the ApplyActionResponse is just an empty JSON object. Does this mean that nothing can be returned from the endpoint?

stevenc
  • 5
  • 3

1 Answers1

0

Short Answer: Not today

Possible workarounds:

  • Generate the unique id for the object on the client and make a get request for that object after the post request finishes. This is what I've done in the past. I usually use UUIDs for this since other sorts of primary keys may not be unique (e.g. an incrementing integer). In any case, best to include retry logic in the event your PK is not unique.
  • If you're calling the API from a server that Foundry can communicate with, you could potentially add a webhook to your Action that would send whatever data you need to send to your server. I haven't tested this, but it seems like it should be possible.
Ontologize
  • 286
  • 6
  • There might be another workaround: on the object type, save the user id (uuid in the user's Foundry rid). Then, after object creation use a named Query API endpoint to get the most recent object created by that user. This has limited applicability (e.g. if users can create multiple objects in one request, etc.), but could be applicable to certain situations. Link to docs on Queries: https://www.palantir.com/docs/foundry/functions/query-functions/#example-api-named-query – Ontologize Jul 19 '23 at 22:22