HTTP Request populating JSON parameter needs to be valid JSON error when trying to dynamically reference input from prior nodes

Describe the problem/error/question

I am trying to dynamically reference an input in my HTTP request node. I would like to send a custom HTTP request to Wordpress to publish a blog post automatically. I have manually inputted the following JSON and the post was successfully created on my word press site:

JSON (Expression):
{
“title”: “THIS IS A TEST FOR A FORUM”,
“content”: “Hello thank you for looking into this problem for me”,
“status”: “publish”
}
Wordpress output:

Here are my HTTP Parameters:
Method: Post
URL: https://protexlawn.com/wp-json/wp/v2/posts
Authentication: None
Send Query Parameters: Off
Send Headers: On
Specify Headers: Using JSON
JSON:
{
“Authorization”: “Basic My access key that I am confident I shouldn’t type here despite being a complete coding noob”,
“Content-Type”: “application/json”
}
Send Body: On
Body Content Type: JSON
Specify Body: Using JSON
JSON:

{{
{
“title”: “$(‘Edit Fields1’).first().json[‘Title’]”,
“content”: “$json[‘blogPost’]”,
“status”: “publish”
}
}}

What is the error message (if any)?

The error I get is JSON parameter needs to be valid JSON.

Please share your workflow

The Entire WorkFlow for reference:

Information on your n8n setup

  • n8n version: 1.76.1
  • Database (default: SQLite): IDK what this means but I am using Airtable
  • n8n EXECUTIONS_PROCESS setting (default: own, main): i think default but idk what this means
  • Running n8n via (Docker, npm, n8n cloud, desktop app): running it via docker container on a vps.
  • Operating system: VPS is linux

Hi @Gallows_Media

You put everything in one code block making it annoying to get the actual workflows.
Please have a seperate code block for each of the things you are sharing.

I have separated out the workflows there in two different code blocks. Again thank you for taking the time to review my issue here.

you still have some other stuff in that first block.
Also in the Second.
I don’t want to be an *ss here but If you want free help you need to make sure we can just click the copy button and paste it in our env to test and help you out.

Sorry, like I said I am still learning. I understand I need to make it easier but I dont really know how just yet. Could you provide a little bit more guidance?

To copy paste this into an n8n instance all the other stuff cannot be there. as n8n only accepts clean JSON of a workflow/node

1 Like

Thank you for your patience. I believe I have successfully updated it so it works more conveniently for you.

Hi @Gallows_Media

Now there is no test data.

Why not use the option for using field below? that would be a lot simpler for you and should not result in the error you are getting.
image

1 Like

Your suggestion did indeed fix the issue. Thank you good sir.

2 Likes

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