Michael Schwartz
07/03/2025, 6:17 PM{
"event": "pim.unifyd.catsy",
"resource": {
"prefect.resource.id": "pim.unifyd.catsy.handle",
"payload": "{{ body }}"
}
}
how to update so that it will accept a json str as body- currently it throws a 400Marvin
07/03/2025, 6:17 PMMarvin
07/03/2025, 6:18 PM{{ body }}
template variable needs to be properly escaped as JSON. Here's the corrected template:
json
{
"event": "pim.unifyd.catsy",
"resource": {
"prefect.resource.id": "pim.unifyd.catsy.handle",
"payload": {{ body | tojson }}
}
}
The key change is using the tojson
Jinja2 filter (| tojson
). This filter ensures that:
1. The JSON string is properly escaped
2. The resulting webhook template produces valid JSON
3. The payload maintains its JSON structure rather than being treated as a plain string
If you're sending the webhook request programmatically, make sure to:
1. Set the Content-Type
header to application/json
2. Send the body as proper JSON, not a string representation of JSON
For example, if you're using Python requests:
python
import requests
import json
payload = {
"some_key": "some_value"
}
response = <http://requests.post|requests.post>(
"your_webhook_url",
json=payload, # This automatically sets the correct Content-Type header
headers={
"Accept": "application/json"
}
)
If you're still getting a 400 error after making these changes, please share:
1. An example of the JSON payload you're trying to send
2. The method you're using to send the webhook (curl, Python, etc.)
This will help me provide more specific guidance.Michael Schwartz
07/03/2025, 6:20 PM{
"id": "06866c9a-c6d3-7882-8000-3b45ad481e80",
"account": "1f68ce6c-568d-4d7a-ae99-9641099300bd",
"event": "prefect-cloud.webhook.failed",
"occurred": "2025-07-03T18:19:24.426Z",
"payload": {
"method": "POST",
"headers": {
"host": "api.prefect.cloud",
"user-agent": "python-requests/2.32.3",
"accept-encoding": "gzip, deflate",
"accept": "*/*",
"content-type": "application/json",
"content-length": "3336",
"x-request-id": "97d2c8e4-59b5-9374-bc7a-41a6da081a59"
},
"body": "{\"data\": [{\"__record_id\": \"variant_id1__unifydmaster\", \"__unifyd_master\": \"1\", \"category_src_normalized\": \"Flower\", \"strain_dict_extract2\": \"WEDDING PIE\", \"product_id_src\": \"fa6c87ff5ca1ba3abe0c78dd2830b420\", \"source\": \"dutchie\", \"uom\": \"gram\", \"price\": \"21.0\", \"product_id\": null, \"segment\": \"Buds\", \"state\": \"Ontario\", \"cannabis_type\": \"INDICA\", \"brand\": \"BACK FORTY\", \"product_presentation\": \"3.50 gram\", \"strain\": \"WEDDING PIE\", \"variant_url\": \"<https://dutchie.com/dispensary/true-north-cannabis-welland/product/wedding-pie-wedding-cake-x-grape-pie-3-5g>\", \"image_url\": \"<https://askhoodie.com/cdn-cgi/image/quality=50/https://data-item-images.s3.us-east-2.amazonaws.com/success/8b722e52bbe3e2406b93365aaef8c589>\", \"thc_mg\": null, \"measure\": \"3.5\", \"brand_src\": \"Back Forty\", \"pos_product_id\": \"2d5eb46c-ebee-4728-af45-89e560380ef5\", \"cbd_mg\": null, \"market_weight\": null, \"sub_category\": \"\", \"matching_product_line\": \"\", \"description\": \"Perfect for those sunny afternoons in the Back Forty, Wedding Pie is the marriage of Wedding Cake x Grape Pie. This strain can reach potencies of up to 28% and is grown with organic practices in an advanced hybrid greenhouse. These vibrant green buds also have a flair of purple, 2.89% total terpene content and a spicy, cracked pepper profile. The top terpenes are trans-caryophyllene, linalool, far\", \"category_src\": \"Flower\", \"menu_id\": \"b662394917c89b0ea174bc87cfeb2e4f\", \"product_id_sql\": null, \"first_seen_at\": \"2022-01-28T03:01Z\", \"item_name\": \"Back Forty Wedding Pie Indica 3.5g\", \"parent_brand\": \"BACK FORTY\", \"subseGment\": null, \"strain_src\": null, \"brand_tier\": null, \"category\": \"Flower\", \"attr_to_drop\": \"3\"}, {\"__record_id\": \"variant_id2__unifydmaster\", \"__unifyd_master\": \"1\", \"category_src_normalized\": \"Flower\", \"strain_dict_extract2\": \"WEDDING PIE\", \"product_id_src\": \"fa6c87ff5ca1ba3abe0c78dd2830b420\", \"source\": \"dutchie\", \"uom\": \"gram\", \"price\": \"21.0\", \"product_id\": null, \"segment\": \"Buds\", \"state\": \"Ontario\", \"cannabis_type\": \"INDICA\", \"brand\": \"BACK FORTY\", \"product_presentation\": \"3.50 gram\", \"strain\": \"WEDDING PIE\", \"variant_url\": \"<https://dutchie.com/dispensary/true-north-cannabis-welland/product/wedding-pie-wedding-cake-x-grape-pie-3-5g>\", \"image_url\": \"<https://askhoodie.com/cdn-cgi/image/quality=50/https://data-item-images.s3.us-east-2.amazonaws.com/success/8b722e52bbe3e2406b93365aaef8c589>\", \"thc_mg\": null, \"measure\": \"3.5\", \"brand_src\": \"Back Forty\", \"pos_product_id\": \"2d5eb46c-ebee-4728-af45-89e560380ef5\", \"cbd_mg\": null, \"market_weight\": null, \"sub_category\": \"\", \"matching_product_line\": \"\", \"description\": \"Perfect for those sunny afternoons in the Back Forty, Wedding Pie is the marriage of Wedding Cake x Grape Pie. This strain can reach potencies of up to 28% and is grown with organic practices in an advanced hybrid greenhouse. These vibrant green buds also have a flair of purple, 2.89% total terpene content and a spicy, cracked pepper profile. The top terpenes are trans-caryophyllene, linalool, far\", \"category_src\": \"Flower\", \"menu_id\": \"b662394917c89b0ea174bc87cfeb2e4f\", \"product_id_sql\": null, \"first_seen_at\": \"2022-01-28T03:01Z\", \"item_name\": \"Back Forty Wedding Pie Indica 3.5g\", \"parent_brand\": \"BACK FORTY\", \"subsegment\": null, \"strain_src\": null, \"brand_tier\": null, \"category\": \"Flower\", \"scenT\": \"ms test 0626\"}], \"dry_run\": false}",
"rendered": "{\n \"event\": \"pim.unifyd.catsy\",\n \"resource\": {\n \"prefect.resource.id\": \"pim.unifyd.catsy.handle\",\n \"payload\": \"{\"data\": [{\"__record_id\": \"variant_id1__unifydmaster\", \"__unifyd_master\": \"1\", \"attr_to_drop\": \"3\", \"brand\": \"BACK FORTY\", \"brand_src\": \"Back Forty\", \"brand_tier\": null, \"cannabis_type\": \"INDICA\", \"category\": \"Flower\", \"category_src\": \"Flower\", \"category_src_normalized\": \"Flower\", \"cbd_mg\": null, \"description\": \"Perfect for those sunny afternoons in the Back Forty, Wedding Pie is the marriage of Wedding Cake x Grape Pie. This strain can reach potencies of up to 28% and is grown with organic practices in an advanced hybrid greenhouse. These vibrant green buds also have a flair of purple, 2.89% total terpene content and a spicy, cracked pepper profile. The top terpenes are trans-caryophyllene, linalool, far\", \"first_seen_at\": \"2022-01-28T03:01Z\", \"image_url\": \"<https://askhoodie.com/cdn-cgi/image/quality=50/https://data-item-images.s3.us-east-2.amazonaws.com/success/8b722e52bbe3e2406b93365aaef8c589>\", \"item_name\": \"Back Forty Wedding Pie Indica 3.5g\", \"market_weight\": null, \"matching_product_line\": \"\", \"measure\": \"3.5\", \"menu_id\": \"b662394917c89b0ea174bc87cfeb2e4f\", \"parent_brand\": \"BACK FORTY\", \"pos_product_id\": \"2d5eb46c-ebee-4728-af45-89e560380ef5\", \"price\": \"21.0\", \"product_id\": null, \"product_id_sql\": null, \"product_id_src\": \"fa6c87ff5ca1ba3abe0c78dd2830b420\", \"product_presentation\": \"3.50 gram\", \"segment\": \"Buds\", \"source\": \"dutchie\", \"state\": \"Ontario\", \"strain\": \"WEDDING PIE\", \"strain_dict_extract2\": \"WEDDING PIE\", \"strain_src\": null, \"sub_category\": \"\", \"subseGment\": null, \"thc_mg\": null, \"uom\": \"gram\", \"variant_url\": \"<https://dutchie.com/dispensary/true-north-cannabis-welland/product/wedding-pie-wedding-cake-x-grape-pie-3-5g>\"}, {\"__record_id\": \"variant_id2__unifydmaster\", \"__unifyd_master\": \"1\", \"brand\": \"BACK FORTY\", \"brand_src\": \"Back Forty\", \"brand_tier\": null, \"cannabis_type\": \"INDICA\", \"category\": \"Flower\", \"category_src\": \"Flower\", \"category_src_normalized\": \"Flower\", \"cbd_mg\": null, \"description\": \"Perfect for those sunny afternoons in the Back Forty, Wedding Pie is the marriage of Wedding Cake x Grape Pie. This strain can reach potencies of up to 28% and is grown with organic practices in an advanced hybrid greenhouse. These vibrant green buds also have a flair of purple, 2.89% total terpene content and a spicy, cracked pepper profile. The top terpenes are trans-caryophyllene, linalool, far\", \"first_seen_at\": \"2022-01-28T03:01Z\", \"image_url\": \"<https://askhoodie.com/cdn-cgi/image/quality=50/https://data-item-images.s3.us-east-2.amazonaws.com/success/8b722e52bbe3e2406b93365aaef8c589>\", \"item_name\": \"Back Forty Wedding Pie Indica 3.5g\", \"market_weight\": null, \"matching_product_line\": \"\", \"measure\": \"3.5\", \"menu_id\": \"b662394917c89b0ea174bc87cfeb2e4f\", \"parent_brand\": \"BACK FORTY\", \"pos_product_id\": \"2d5eb46c-ebee-4728-af45-89e560380ef5\", \"price\": \"21.0\", \"product_id\": null, \"product_id_sql\": null, \"product_id_src\": \"fa6c87ff5ca1ba3abe0c78dd2830b420\", \"product_presentation\": \"3.50 gram\", \"scenT\": \"ms test 0626\", \"segment\": \"Buds\", \"source\": \"dutchie\", \"state\": \"Ontario\", \"strain\": \"WEDDING PIE\", \"strain_dict_extract2\": \"WEDDING PIE\", \"strain_src\": null, \"sub_category\": \"\", \"subsegment\": null, \"thc_mg\": null, \"uom\": \"gram\", \"variant_url\": \"<https://dutchie.com/dispensary/true-north-cannabis-welland/product/wedding-pie-wedding-cake-x-grape-pie-3-5g>\"}], \"dry_run\": false}\"\n }\n}",
"compiled": null,
"reason": "unexpected character: line 5 column 19 (char 121)"
},
"received": "2025-07-03T18:19:24.426Z",
"related": [],
"resource": {
"prefect.resource.id": "prefect-cloud.webhook.283c8f61-321f-4336-99a8-b679b2206dbf",
"prefect.resource.name": "Upsert Catsy Products"
},
"workspace": "8f854e6c-4fe7-49b7-860c-8f2e7973c905"
}
Marvin
07/03/2025, 6:20 PM