0

I'm trying to create a webhook with multiple calls on a direct connection REST-API in Palantir. The first call is to get a token and then pass it to second call and post some data to the source.

But when i'm saving the webhook, its throwing an error that it is Invalid Rest Webhook Configuration.

Safe Error Message: Can have at most one safe call.

When i checked the documentation it mentioned that we should specify isHttpMethodSafe as true in the call. Where should i set this?

DR_S
  • 77
  • 9

2 Answers2

1

For the token use case, you can fetch the token in the Magritte Source and assign it to the header of every request. This makes defining it in the Webhook not necessary.

type: magritte-rest-v2
sourceMap:
  authentication_source:
    type: magritte-rest
    url: https://<base-url-to-auth>/
  api_source:
    type: magritte-rest-auth-call-source
    url: https://<base-url-to-api>/
    headers:
      Authorization: Bearer {%token%}
    authCalls:
      - source: authentication_source
        type: magritte-rest-call
        path: <path-to-token-endpoint>/api/oauth2/token
        method: POST
        formBody:
          grant_type: client_credentials
          client_id: 'demo'
          client_secret: '{{client_secret}}'
          scope: ''
        extractor:
          - type: magritte-rest-json-extractor
            assign:
              token: /access_token

nicornk
  • 654
  • 3
  • 11
1

Short Answer: I don't think this is possible today when using a Direct Connection Source, but I do think it would work with an Agent-based Source.

Details: That part of the documentation you reference is under the Rest API (Legacy) section. Using the docs on this page that describe the legacy version in more detail, I was able to create a Direct Connection source by starting from scratch with a Custom Connector. However, when I go to create a Webhook for that source, I see this message: "Webhooks are not yet supported for cloud-based runtimes". That makes me think that your only option is to create an Agent-based Source for this webhook.

webhook not supported

In my opinion, enabling isHttpMethodSafe in the current Direct Connection Rest API source would be a very reasonable feature request for you to make to your Palantir representative. After all, today if you open your network tab when you load a Webhook in Data Connection you can see that isHttpMethodSafe is set to null in the response delivering all the details about the Webhook you're looking at (look for a request to /ri.webhooks.main.webhook.<uuid>).

Ontologize
  • 286
  • 6