Describe the issue/error/question
Hello, Thanks in advance for your help. It seems everytime I try something in n8n, I get a new set of questions to solve.
I hope to turn things around soon.
I need to query a custom API , fetch some data such as products’ sku, quantity in stock, and other related data. After I’ve queried the API, I will merge fields and discard other, to put it into a spreadsheet.
However, I cannot get to loop through the API pagination. How can I do that?
What is the error message (if any)?
No erros, just empty result.
Please share the workflow
This is the output returned by the API from a GET to the inventory endpoint. The important part that I need to modify to loop is in the value “next” , to page=3 , page=4 and so on. The last page has the value of “null”. That is why in the IF node I am setting this as the condition to continue looping.
{
"count": 24979,
"next": "http://mycustomapi/stock/?page=2",
"previous": null,
"results": [
{
"cve_art": "09157948",
"descr": "No. De Parte Remplazado por: 9157948",
"lin_prod": "9INTE",
"con_serie": "N",
"uni_med": "pz",
"uni_emp": 1.0,
"ctrl_alm": null,
"tiem_surt": 0,
"stock_min": 0.0,
"stock_max": 0.0,
"tip_costeo": "P",
"num_mon": 1,
"fch_ultcom": null,
"comp_x_rec": 0.0,
"fch_ultvta": null,
"pend_surt": 0.0,
"exist": 0.0,
"costo_prom": 0.0,
"ult_costo": 0.0,
"cve_obs": 0,
"tipo_ele": "P",
"uni_alt": "pz",
"fac_conv": 1.0,
"apart": 0.0,
"con_lote": "N",
"con_pedimento": "N",
"peso": 0.0,
"volumen": 0.0,
"cve_esqimpu": 1,
"cve_bita": null,
"vtas_anl_c": 0.0,
"vtas_anl_m": 0.0,
"comp_anl_c": 0.0,
"comp_anl_m": 0.0,
"prefijo": null,
"talla": null,
"color": null,
"cuent_cont": null,
"cve_imagen": null,
"blk_cst_ext": "N",
"status": "A",
"man_ieps": "S",
"apl_man_imp": 1,
"cuota_ieps": 0.0,
"apl_man_ieps": "C",
"uuid": "5A14CDFA-5E57-4B32-AC0F-6AE4A9BB520A",
"version_sinc": "2022-05-26T15:39:12.019000Z",
"version_sinc_fecha_img": null,
"cve_prodserv": "25172000",
"cve_unidad": "H87",
"edo_publ_ml": null,
"cve_publ_ml": null,
"condicion_ml": null,
"tipo_publ_ml": null,
"modo_envio_ml": null,
"largo_ml": null,
"alto_ml": null,
"ancho_ml": null,
"envio_ml": null,
"categ_ml": null,
"campos_categ_ml": null,
"disponible_publ": null,
"cve_cate_ml": null,
"last_update_ml": null,
"f_crea_ml": null,
"imagen_ml": null,
"en_catalogo": null,
"id_catalogo": null,
"titulo_ml": null,
"mat_peli": null
},
{some 20 more products}
]
}
Information on your n8n setup
- n8n version: n8n@0.178.1
- Database you’re using (default: SQLite): yes
- Running n8n with the execution process [own(default), main]: no idea
- Running n8n via [Docker, npm, n8n.cloud, desktop app]: docker