GET differnet images via HTTP Request depending on how many images are available

Hey there, I am quite new to n8n and I already love it.

I am facing following problem:

I need to pull images via HTTP Request node with a specific url. Before that node I get the information how many images are available by a specific number.

So in that HTTP Request node I GET one image easily by just adding the image position after the URL.

https:// example. com/image.ashx?image-number=1

As the Node before the HTTP Request is just saying “how many images” are available and with that one HTTP Request node I am calling the “image by their position” I want to find out how can I run that HTTP Request X times depending on how many images are available and also make a different output for every image, depending on what position it is at.

For example, the Node before the HTTP Request gives 5 (5 Images are available) it should do the following.

HTTP Request Node Calls via GET:
https:// example. com/image.ashx?image-number=1
https:// example. com/image.ashx?image-number=2
https:// example. com/image.ashx?image-number=3
https:// example. com/image.ashx?image-number=4
https:// example. com/image.ashx?image-number=5

And gives a binary file output like:
image-1.jpg
image-2.jpg
image-3.jpg
image-4.jpg
image-5.jpg

I really appreciate some help. Thank you

You can use the Function node to explode the count into separate records like this:

Thank you drudge thats perfect.
Still there is one problem, I guess did not think about it on my first question.

The info which I am getting before the HTTP Request node is giving a Product-ID and Product-Location which is also in that image call URL.

For Example:

https:// example. com/image.ashx?product-id=10&product-location=3&image-number=1

Now when I call only one product image its working like a charm but on multiple products it will do the HTTP Request for products which do not have the same number of images, which is resulting in a error.

Next is the output of the HTTP Request needs to be specified so that every image can be traced back to Product-ID, Product-Location and Image-Number by its name.

So if I call this URL:

https:// example. com/image.ashx?product-id=10&product-location=3&image-number=1

it should result in:

10_3_1.jpg

and that also if there are multiple products which each multiple images.

In my example, the Set node would represent the HTTP Request node that contains your product ID, location, and number of images properties.

If you change this line in the Function node:

    returned.push({ json: { image_number } });

to:

    returned.push({ json: { ...item.json, image_number } });

You’ll receive separate items, all with the data of the item being sent in but with the additional image_number property added.

This should allow you to map the additional parameters in your GET of the resulting image.

1 Like

Thank you very much, that was exactly what I needed.

1 Like