Help with Passing Multiple Parameters in a variable

Describe the issue/error/question

I am trying to utilize the sendgrid api in order to create a new subuser, in order to do this i need o create a number of variable along with the IP address.

This is the documentation from sendgrid:
curl -X POST https://api.sendgrid.com/v3/subusers
–header “Authorization: Bearer <<YOUR_API_KEY_HERE>>”
–data “{‘username’: ‘[email protected]’, ‘email’: ‘[email protected]’, ‘password’: ‘johns_password’, ‘ips’: [‘1.1.1.1’, ‘2.2.2.2’]}”

What is the error message (if any)?

{“status”:“rejected”,“reason”:{“message”:“400 - {“errors”:[{“message”:“Encountered problem reading the postbody”}]}”,“name”:“Error”,“stack”:“Error: Request failed with status code 400\n at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:269:11)\n at IncomingMessage.emit (events.js:327:22)\n at endReadableNT (internal/streams/readable.js:1327:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)”}}

Please share the workflow

Information on your n8n setup

  • n8n version: 0.158.0

Hi @Surge.Media, this 400 error would come from Sendgrid. The status code usually indicates the request doesn’t quite match what the server expects.

From looking at your example from the Sendgrid documentation, Sendgrid seems to expect an array inside the ips field so you might need to use the JSON/RAW Parameters option of the HTTP Request node here.

Could you share the data you are getting from your Sendgrid Get IPS node? You can of course change the actual IPs to some fantasy values, this just to get an idea of the data structure you are working with here.

Hi @MutedJam

I am unfamiliar with with how to define the JSON/RAW data.

This is the output from the get IPS:

[
  [
    {
      "ip": "112.112.112.212",
      "subusers": [
        "[email protected]",
        "SurgeTest"
      ],
      "pools": [],
      "warmup": false,
      "start_date": null,
      "whitelabeled": false,
      "assigned_at": 1643188546
    }
  ]
]

Thanks! I think this approach might work (it wraps the IP inside an array which seems to be what Sendgrid expects based on your example):

that did the trick! Thank you very much

1 Like