How to HTTP request an API

I need to send some data from a webhook to a platform’s API.

I’m managing to extract the data from the webhook, but when I send the data to the API, it’s giving an error.

Here is the API documentation: Hyros · Apiary

I need to send the “email”, “name” and “price”. The last two are inside the “items” array so I’m not sure how to do that.

I don’t know if you can do this using the fields or if I need to send everything through a JSON code.

It is giving the following error:

{"status":"rejected","reason":{"message":"400 - \"{\\\"result\\\":\\\"ERROR\\\",\\\"message\\\":[\\\"Missing required field: Items\\\"]}\"","name":"Error","stack":"Error: 400 - \"{\\\"result\\\":\\\"ERROR\\\",\\\"message\\\":[\\\"Missing required field: Items\\\"]}\"\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 (node:events:525:35)\n    at IncomingMessage.emit (node:domain:489:12)\n    at endReadableNT (node:internal/streams/readable:1358:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)"}}

Here’s a screenshot:
[ removed for security reasons ]

Hey @migma,

Welcome to the community :cake:

Hopefully you didn’t share your actual API key in the screenshot, I would start by moving that to a Credential under Authentication > Generic > Header

The error coming back is the API telling you that it can’t find the items field. I would maybe start by sending the data to something like webhook.site without the credentials to make sure the data is what you would expect it to be.

yeah i would revoke that API key, maybe even delete the screenshot

Hi @migma, welcome to the community. As the others already mentioned, please delete your Screenshot to protect your own safety.

Regarding your error, you need to send the price and name via an items array, like you already mentioned. It could look something like this:

Hope that helps

in fact @Jon can you remove the screenshot for the users protection re: the exposed api key?

1 Like

Ah, I found out that I can also do that. Removed for now :slight_smile:

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.