Hi! I’m trying to build a flow in Activepieces where I:
Loop through WordPress posts (fetched via API)
Use OpenAI to generate updated content
Send that new content back to WordPress via a POST request using either “HTTP Request” or “Custom API Call”
My issue:
No matter how I structure the request, Activepieces doesn’t seem to send the JSON correctly. Instead of sending a proper object with fields like title and content, the body ends up either being a plain string, or wrapped in a data field.
I’ve tried:
Setting the Body Type to JSON
Using dynamic mode (f(x))
Writing raw JSON manually
Using a code step to build the body
Switching between HTTP Request and WordPress Custom API Call
But WordPress always returns errors, saying the body is malformed or missing fields.
My question:
Is there a reliable way to send a dynamic JSON body in Activepieces — with multiple fields — to an external API like WordPress?
If anyone has solved this or has a sample that works inside a loop, I’d love to learn how you did it.
Thanks for sharing the screenshot! I noticed three things!
Quick check, are you trying to create a new post or trying to update one? Doesn’t matter though I will give both examples below, using google as a example domain.
Creating a new post your URL should look like this: (currently the Looped item is in there)
Content-Type in the left field and application/json in the right field
For the body part you need to make sure that atleast the Title and the Content of the post are there: You structure should look as follows:
{
“title”:“put your title here”,
“content”:“put your content here”,
“status”:“draft”
}
(Please make sure the " are straight like this one " and nor curly like in the example) for some reason it gave me this markdown.
Please try it with this data, change your domainname, this way we can make sure the connection is working by creating a draft post from there we can move towards the variable your are looking for.
Let me know how this works, please provide some screenshots/recordings of the results to work further with.
Please modify these items and let me know the outcome.
Also for testing, please use some hard coded data not dynamic, this helps in making sure all the details are correct. so please use the id of 7518 and also for content and title in the body
Ah. I could do it like this I guess. So I wont flood the post.
It was a limit, so I cut some things in the middle. But i see my boddy message in the end, and I guess the starting point is important.
I couldnt find away to upload text documents or similar.
"\"{\\\"response\\\":{\\\"status\\\":404,\\\"body\\\":\\\"<!DOCTYPE html>\\\\r\\\\n<html lang=\\\\\\\"sv-SE\\\\\\\">\\\\r\\\\n<head>\\\\r\\\\n\\\\t<meta charset=\\\\\\\"UTF-8\\\\\\\" />\\\\r\\\\n\\\\t<meta name=\\\\\\\"viewport\\\\\\\" content=\\\\\\\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\\\\\\\" />\\\\r\\\\n\\\\t<link rel=\\\\\\\"pingback\\\\\\\" href=\\\\\\\"https://www.katrineholmsguiden.se/xmlrpc.php\\\\\\\">\\\\r\\\\n\\\\r\\\\n\\\\t<!-- Kodblock för frånsägning av ”Google Analytics”, tillagt av Site Kit -->\\\\n\\\\t\\\\t<!-- Avslut av kodblock för frånsägning av ”Google Analytics”, tillagt av Site Kit -->\\\\n\\\\t<meta name='robots' content='noindex, follow' />\\\\n\\\\n\\\\t<!-- This site is optimized with the Yoast SEO plugin v24.8.1 - https://yoast.com/wordpress/plugins/seo/ -->\\\\n\\\\t<title>Sidan hittades inte - Katrineholmsguiden</title>\\\\n\\\\t<!-- Meddelande endast till administratören: Denna sida visar ingen metabeskrivning eftersom den inte har någon. Skriv antingen en specifik beskrivning för denna sida eller gå till menyn [Yoast SEO - Inställningar] och skapa en mall. -->\\\\n\\\\t<meta property=\\\\\\\"og:locale\\\\\\\" content=\\\\\\\"sv_SE\\\\\\\" />\\\\n\\\\t<meta property=\\\\\\\"og:title\\\\\\\" content=\\\\\\\"Sidan hittades inte - Katrineholmsguiden\\\\\\\" />\\\\n\\\\t<meta property=\\\\\\\"og:site_name\\\\\\\" content=\\\\\\\"Katrineholmsguiden\\\\\\\" />\\\\n\\\\t<script type=\\\\\\\"application/ld+json\\\\\\\" class=\\\\\\\"yoast-schema-graph\\\\\\\">{\\\\\\\"@context\\\\\\\":\\\\\\\"https://schema.org\\\\\\\",\\\\\\\"@graph\\\\\\\":[{\\\\\\\"@type\\\\\\\":\\\\\\\"WebSite\\\\\\\",\\\\\\\"@id\\\\\\\":\\\\\\\"https://www.katrineholmsguiden.se/#website\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://www.katrineholmsguiden.se/\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Katrineholmsguiden\\\\\\\",\\\\\\\"description\\\\\\\":\\\\\\\"Att göra i Katrineholm\\\\\\\",\\\\\\\"potentialAction\\\\\\\":[{\\\\\\\"@type\\\\\\\":\\\\\\\"SearchAction\\\\\\\",\\\\\\\"target\\\\\\\":{\\\\\\\"@type\\\\\\\":\\\\\\\"EntryPoint\\\\\\\",\\\\\\\"urlTemplate\\\\\\\":\\\\\\\"https://www.katrineholmsguiden.se/?s={search_term_string}\\\\\\\"},\\\\\\\"query-input\\\\\\\":{\\\\\\\"@type\\\\\\\":\\\\\\\"PropertyValueSpecification\\\\\\\",\\\\\\\"valueRequired\\\\\\\":true,\\\\\\\"valueName\\\\\\\":\\\\\\\"search_term_string\\\\\\\"}}],\\\\\\\"inLanguage\\\\\\\":\\\\\\\"sv-SE\\\\\\\"}]}</script>\\\\n\\\\t<!-- / Yoast SEO plugin. -->\\\\n\\\\n\\\\n<link rel='dns-prefetch' href='//maps.googleapis.com' />\\\\n<link rel='dns-prefetch' href='//cdnjs.cloudflare.com' />\\\\n<link rel='dns-prefetch' href='//fonts.googleapis.com' />\\\\n<link rel='dns-prefetch' href='//www.googletagmanager.com' />\\\\n<link rel=\\\\\\\"alternate\\\\\\\" type=\\\\\\\"application/rss+xml\\\\\\\" 3px;\\\\\\\"></div>\\\\r\\\\n\\\\t\\\\t\\\\t</div>\\\\r\\\\n\\\\t\\\\t</div>\\\\r\\\\n\\\\t</div>\\\\r\\\\n</div>\\\\t</div>\\\\r\\\\n</div>\\\\r\\\\n<!-- Modal - WC Cart Contents-->\\\\r\\\\n<div id=\\\\\\\"wc-cart-modal\\\\\\\" class=\\\\\\\"modal modal-27\\\\\\\" role=\\\\\\\"dialog\\\\\\\">\\\\r\\\\n <div class=\\\\\\\"modal-dialog modal-md\\\\\\\">\\\\r\\\\n\\\\t <div class=\\\\\\\"modal-content\\\\\\\">\\\\r\\\\n\\\\t <div class=\\\\\\\"sign-in-box\\\\\\\">\\\\r\\\\n\\\\t\\\\t\\\\t\\\\t<div class=\\\\\\\"widget woocommerce widget_shopping_cart\\\\\\\"><h2 class=\\\\\\\"widgettitle\\\\\\\">Varukorg</h2><div {\\\\\\\"ajaxurl\\\\\\\":\\\\\\\"https:\\\\\\\\/\\\\\\\\/www.katrineholmsguiden.se\\\\\\\\/wp-admin\\\\\\\\/admin-ajax.php\\\\\\\",\\\\\\\"nonce\\\\\\\":\\\\\\\"21c1eb31d7\\\\\\\"};\\\\n/* ]]> */\\\\n</script>\\\\n<script type=\\\\\\\"text/javascript\\\\\\\" src=\\\\\\\"https://www.katrineholmsguiden.se/wp-content/plugins/elementskit-lite/widgets/init/assets/js/elementor.js?ver=3.4.8\\\\\\\" id=\\\\\\\"elementskit-elementor-js\\\\\\\"></script>\\\\n</body>\\\\r\\\\n</html>\\\"},\\\"request\\\":{\\\"body\\\":{\\\"title\\\":\\\"Test title\\\",\\\"status\\\":\\\"draft\\\",\\\"content\\\":\\\"This is a test\\\"}}}\""