Skip to content

fix: Enable to add headers template in webhooks created dynamically #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025

Conversation

gaelloyoly
Copy link
Contributor

@gaelloyoly gaelloyoly changed the title Being able to add headers template in webhooks created dynamically feat: being able to add headers template in webhooks created dynamically Jun 13, 2025
@gaelloyoly gaelloyoly had a problem deploying to fork-pr-integration-tests June 13, 2025 11:28 — with GitHub Actions Failure
vdusek

This comment was marked as outdated.

@vdusek vdusek requested review from Pijukatel and vdusek June 13, 2025 11:39
@Pijukatel
Copy link
Contributor

Pijukatel commented Jun 13, 2025

@gaelloyoly Hello, thank for the PR. Just to help me understand the context of the change. In what situation do you get "headers_template" key in that dictionary? In other workds, why is it not 'headersTemplate' directly?

@gaelloyoly
Copy link
Contributor Author

@Pijukatel I wanted to create an ad-hoc webhook and I followed the example by passing a dict with payloadTemplate and headerTemplate but none of them was used.
Then I saw that the Webhook data structure in python is using underscores : https://docs.apify.com/sdk/python/reference/class/Webhook
I guess it's to make it more "pythonic". That's why I'm using this for headers too.

@Pijukatel
Copy link
Contributor

Pijukatel commented Jun 13, 2025

@gaelloyoly Could you please describe your top level call (Which client did you use, or did you call some Actor method from Apify SDK?) Because I see, that there is a function that is already responsible for conversion from underscore names: https://github.com/apify/apify-client-python/blob/master/src/apify_client/clients/resource_clients/webhook.py#L24
, but most likely there is some path that is not using this function, so that is why I want to understand how you called it.

@gaelloyoly
Copy link
Contributor Author

gaelloyoly commented Jun 13, 2025

Yes, it's the "start" method of the actor client. I'm doing something like this :

from apify_client import ApifyClient
client = ApifyClient("APIFY_API_KEY")
client.actor("actor_id").start(
    run_input={"url": "input_url"},
    webhooks=[{
        "event_types": ["ACTOR.RUN.SUCCEEDED"],
        "request_url": "https://example.com/success",
        "payload_template": "{{resource}}",
        "headers_template": '{"x-custom-signature": "1234567890"}',
    }],
)

@Pijukatel
Copy link
Contributor

Yes, it's the "start" method of the actor client. I'm doing something like this :

from apify_client import ApifyClient
client = ApifyClient("APIFY_API_KEY")
client.actor("actor_id").start(
    run_input={"url": "input_url"},
    webhooks=[{
        "event_types": ["ACTOR.RUN.SUCCEEDED"],
        "request_url": "https://example.com/success",
        "payload_template": "{{resource}}",
        "headers_template": '{"x-custom-signature": "1234567890"}',
    }],
)

Thank you for the PR and the clarification. I created issue to refactor the part of the code responsible for handling the Webhooks inputs and in the meantime let's merge your PR.

@Pijukatel Pijukatel merged commit b84d1ec into apify:master Jun 16, 2025
26 of 28 checks passed
@Pijukatel Pijukatel changed the title feat: being able to add headers template in webhooks created dynamically fix: Enable to add headers template in webhooks created dynamically Jun 16, 2025
@gaelloyoly
Copy link
Contributor Author

Thanks !

@gaelloyoly gaelloyoly deleted the patch-1 branch June 16, 2025 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants