-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
adhoc fix for a issue on Custom Webhook block: only header no body in the POST request #16870
Conversation
…art in the POST request for the Custom Web Hook
CodSpeed Performance ReportMerging #16870 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening a PR @zelterNN! Unfortunately, this is a breaking change, so we can't accept it as is.
If you want to input the subject, body, and name info in the body of the payload, you can use the json_data
field. The json_data
field accepts templated values, so you could do something like this:
{"subject": "{{subject}}", "body": "{{body}}", "name": "{{name}}"}
for your json_data
field.
Let me know if that works for your use case!
Hi @desertaxle, My use case is: sending flow status change notification to Microsoft Teams thru the Automation / Notification thru the Custom Webhook. All configured from the UI. Here's the issue: on Custom Webhook block itself, the JSON_Data (and other components such as Form Data, Header) is not modifiable. On Automation, there's only Subject and Body that can be filled but they are currenltly fail to generate into the httpx request (what's this PR is trying to solve). I think there're two issues on the current code:
Looking forward Prefect can have a generic fix onto this in the next version. Best, |
@zelterNN it's true that you can't modify the I tested this and was able to get a body in my webhook that looks like this: {
"subject": "Prefect deployment 'sample-v1/rerun_debug' has entered status 'DeploymentStatus.NOT_READY'",
"body": "\nName: sample-v1/rerun_debug\nStatus: DeploymentStatus.NOT_READY\nURL: None",
"name": "from-python"
} I had to create the block in Python because there's an issue with the custom webhook in the UI (#16656), but it seems like it's possible to achieve what you're looking for without any code changes. |
It works! Thank you. I tried different options when creating the Custom Webhook block from Pythoin, it seems no matter I initiate the block with the json or just the default, as long as the block is created (initiated) from the Python instead of GUI, the block will work as expected. |
@desertaxle when i move on to production without patch, there's still some issues: if i initiate the block from Python with json supplied, it will work, but only for static string as in your example. If there're dynamic components such as {{ flow.name }}, {{ deployment.name }}, it will failed. Any workaround on this? |
You might need to have the dynamic parts in the |
@desertaxle but you hint me on something, i tried |
adhoc fix for a issue on Custom Webhook block: only header no body in the POST request
Checklist
<link to issue>
"This issue is related to the discussion on Slack: https://prefect-community.slack.com/archives/CL09KU1K7/p1737742902411919
mint.json
.