Search code examples
palantir-foundrypalantir-foundry-api

Using a Code Repo to call a Webhook created in Palantir Foundry


I've used Foundry's default REST API connector to build a connection to an external API with 3 parameters. Testing the code works fine using the webhooks testing options. Now I want to call the webhook and return the data but I'm at a loss for any method to do that in Foundry. The one thing I've been able to find is a note in the Webhook API Name that says you can use that name to reference it in a code repo but I can't find any examples and my searching through the methods available in code (Python Code Repo) haven't pointed to anything either.

Is connecting to a REST API webhook via the API name using code even possible in a code repo? And if not, what's the point of the REST API connector? It seems pretty powerful but to have it dead end into a webhook and not be able to do anything with it seems like a significant functionality miss for Foundry.


Solution

  • You have a few ways to integrate with an API from Foundry:

    • Use Webhook + Action to trigger the webhook, e.g. from a user clicking on a button in a Workshop applicaiton
    • Use External Transforms to execute python code to perform the API calls and save the result in a dataset. This is fully flexible, as long as you can write code to connect (e.g. using the Python requests library) you should be able to perform the API calls you need. e.g. if you want to load data every hour from a given system/endpoint. You need to setup an egress to whitelist the domain you want to reach.

    You can't call a web-hook from a pipeline or from a function as of today.

    There are more ways, but shouldn't be relevant for your case (legacy methods, etc.)