I don’t use PHP, but it seems your script is simply making a bunch of http requests using the data obtained from MySQL. You can do this in n8n using the HTTP Request node.
You wouldn’t need to use the SplitInBatches node here as the HTTP Request node will (like most nodes) loop through all items incoming items automatically, check out the documentation on looping for more information on this behaviour.
I tried the HTTP Request node, i think this is the way to approach it. Most likely I have to change something, because they asking for a specific format.
[
{
"data": {
"isError": true,
"messages": [
"The call is empty. Please make sure you use POST method."
],
"results": []
}
},
{
"data": {
"isError": true,
"messages": [
"The call is empty. Please make sure you use POST method."
],
"results": []
}
}
]
Hi @Cosonel, I think something like below might do the job:
Keep in mind this example uses a data structure that might not 100% resemble your database. Also it uses a test URL, so you’ll need to adjust the URL and the expressions in the HTTP Request node to suit your data.
[
{
"isError": true,
"messages": [
"Expected list of arrays, single array received. Try to encapsulate the call into another array"
],
"results": [
]
}
]```
Any chance you can use a URL provided by https://webhook.site/ in your PHP script and run it once? You would then be able to view the exact request directly on webhook.site and share it with me, hopefully making it clear how exactly the data structure looks like (credentials and anything else that’s confidential can of course be redacted).
For example, this is what my test request has sent:
Hey @Cosonel, I am very sorry but am not familiar with PHP and can’t confirm how this code translates into HTTP requests. I tried running your script on https://www.phplayground.com/ but it seems curl_init(); isn’t available by default.
Would you be able to simply replace https://marketplace-api.emag.bg/api-3/product_offer/save in your script with a test URL provided by webhook.site? After running your script you should be able to inspect the actual data your library has sent directly on this website.
@MutedJam, unfortunately, they limited the HTTP Request and I can’t use it anymore.
It worked wonderfully, I even put a discord Webhook to receive a message if I have any errors…
Now I need to use API Request, any recommendation?
Hi @Cosonel, the HTTP Request node is already sending an API request to a destination of your choice. If the destination rejects the request you might need to check why that’s the cause. Are you sending too many requests perhaps?