Raw data into the body of a post request

Describe the issue/error/question

Hi, I’m currently doing a POST request thanks to the http node. I setup my request first using postman, and to make the request working, I need the content of the body to be just a string. So I would like to put the body content type in “raw” but let the headers in json, or setup them in “raw” but I don’t know if it’s possible. So I setup my node but I get the error below :

What is the error message (if any)?

ERROR: Cannot create property ‘accept’ on string ‘{“content-type”: “application/x-www-form-urlencoded”, “x-rapidapi-host”: “canssens-seo-extraction-v1.p.rapidapi.com”, “x-rapidapi-key”: “my-private-key”}’

Please share the workflow

This is the node :

{
  "nodes": [
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "=https://canssens-seo-extraction-v1.p.rapidapi.com/seo/api/",
        "jsonParameters": true,
        "options": {
          "bodyContentType": "raw"
        },
        "bodyParametersJson": "url=https://www.secretsdeloly.com",
        "headerParametersJson": "{\"content-type\": \"application/x-www-form-urlencoded\", \"x-rapidapi-host\": \"canssens-seo-extraction-v1.p.rapidapi.com\", \"x-rapidapi-key\": \"my-private-key\"}"
      },
      "name": "seo-page1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        540,
        2340
      ]
    }
  ],
  "connections": {}
}
(Select the nodes and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow respectively)

The API that I use : SEO extraction API Documentation (Canssens) | RapidAPI

Thanks Guys !

Share the output returned by the last node

Information on your n8n setup

  • **n8n version: n8n cloud 0.158
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]:

Hi @jeremy_FRANCOIS, when using the JSON/RAW Parameters option body parameters, headers, and query parameters would all need to be specified as JSON. You also wouldn’t need to set the content type in the headers field, that would be specified via the respective dropdown.

So with this in mind I think the below should work:

Let me know if you run into any trouble with this :slight_smile:

Hi @MutedJam , thank you, it works !

1 Like

Glad to hear, thanks a lot for confirming :slight_smile:

1 Like