Can't send dynamic JSON body in Activepieces – WordPress API not receiving it correctly

Hi! I’m trying to build a flow in Activepieces where I:

  1. Loop through WordPress posts (fetched via API)
  2. Use OpenAI to generate updated content
  3. 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!

Hi Lars,

Could you provide us some screenshots/recordings to help investigate the issue?

KR Bram

Hi,

Not sure if u can see anything from the screenshot here?

Hi Lars,

Thanks for sharing the screenshot! I noticed three things!

  1. 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)

https://google.com/wp/v2/posts

For updating a post you should do the following:

https://google.com/wp/v2/posts/id

Where id should be the id of the Wordpress post.

  1. Please add the following header:

Content-Type in the left field and application/json in the right field

  1. 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.

KR Bram

Hi Bram,

Thanks, but it did not really work or me, I tried diffrent variations.

Maybe Im missing something small?

Im trying to update post.

Dont know if the problem also could be in the beginning of the loop. See below.

Hi Lars,

It looks like we are almost there!

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

Hopefully almost.

But not there yet :slight_smile:


HI Lars,

It seems the " of status have been changed

Scherm­afbeelding 2025-04-09 om 09.52.37

Please try again, Also if there is an error could you please paste the entire response here so I can further investigate

Hi Bram,

Sorry for that. I tried again. But no luck.

Input:

{
  "url": {
    "url": "https://www.katrineholmsguiden.se/wp/v2/posts/7518"
  },
  "auth": "**REDACTED**",
  "body": {
    "title": "Test title",
    "status": "draft",
    "content": "This is a test"
  },
  "method": "POST",
  "headers": {
    "Content-Type": "application/json"
  },
  "failsafe": false,
  "queryParams": {}
}

Output: was super long, not sure if you want everything here.

Hi Lars,

Input seems fine now.

It’s the output I need, and there it provides details about what is wrong with the request. You have an option to download the file/copy the output.

Kr Bram

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\\\"}}}\""

Hi Lars,

I overlooked something, please check the URl and add wp-json there too:

/wp-json/wp/v2/posts

this should do the trick.

Please let me know the outcome

KR Bram

Yay! It worked Bram. Thanks a lot.

I guess, now just change the hard coded?

I knew you could do it with a bit of help!

Sure go ahead, I would suggest you first duplicate the piece to keep this original and add the ‘skip’ to it so you can use it as reference.

Good luck, and in case of any need let me know.

1 Like

Many thanks for helping out @Bram :muscle: :muscle:

1 Like

Hi @Abdul

I’ve been quiet busy lately but when i have a few minutes spare I’ll try to do what
I can :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.