How to send a custom request

I want to send a custom request, but it doesn’t work

examples:

Postman:


N8n:

Does anyone know if I can send this same request through n8n?

Hey @leosantosx,

I’ve deleted the n8n output image that you posted. Your token was visible in the image.

Coming back to your question, are you referencing the values from a previous node in the workflow? Can you let us know which URL you’re making a request to? Can you share your workflow? Make sure that you replace sensitive information with dummy data

i want send a custom request

the body parameters are not valid

node:

example of api: Bulk API | Elasticsearch Guide [8.1] | Elastic

Are you making a request to the Elasticsearch API? Did you try the Elasticsearch node?

I don’t currently have this node, I will try to upgrade to the latest version of n8n

thanks for helping :grinning:

No worries! A quick note: the node currently doesn’t support the _bulk endpoint. Feel free to create a Feature Request explaining your use case :slight_smile:

Is it possible to send it by command line?

example:
curl -H ‘authorization: 12345’ -H ‘Content-Type: application/x-ndjson’ -d ‘{“data”…"}’ ‘https://example.com

If you’re self-hosting n8n, you can use the Execute Command node. However, you may want to make sure that curl is installed and accessible.

1 Like

What happens if you remove the \n and \t from the value does that still fail?

\n is required in body

is it required in the header as well?

I tried without \ n and it wasn’t too

I just gave it a quick go here as well, I think what is happening is you are setting the content-type twice which is tripping it up.

Remove the Body Content Type option and that will get you a bit closer but then throws an error about your JSON body being invalid which a couple of online tools confirms so if you test with a simpler json value that is valid it goes through ok.

image

but the body is required to be like this:
{“index”:{"_id":“sellout_1”}} {“product_id”:“123456”, “distribution_node_id”:“S020”,“sellout_date”:“2021-08-16”,“sellout_quantity”: 0.123,“sellout_amount”:20.0}

That makes it tricky then as the json isn’t valid it is going to fail, the curl option from the execute command node might be the best option but I will have another play.

Hey @leosantosx!

Another alternative is to use the request library in the Function node. Again, if you’re self-hosting n8n you may want to make the library accessible. You can find more about this here: [HELP] Not been able to import external modules - #8 by jan

If you’re using n8n.cloud, you can simply import the library and use it.

can you make me this feature request?
I really need to send a bulk :slightly_frowning_face:

Hey @leosantosx!

I’ve turned this into a Feature Request. Don’t forget to upvote :slight_smile:

2 Likes