#Retrieving data from external API using flows

13 messages · Page 1 of 1 (latest)

short gazelle
#

Hi, I'm new with Directus so be gentil with me. What i want to know if it's possible to use flow to retrieve data from external api and insert it into my database. I tried with webhook / request url and i did on succes and on error operations and i get the error. So, what i need is:

  • to know if is possible to retrieve data from external API and if yes how can I do it.
  • to know how can i log the returned error message to see if it's somehow my fault in making the request header or other things.
  • if I can get the response how can I log it?
    Thank you!
twilit sluiceBOT
#

Thanks for posting! This is a community powered server, so you may or may not get an answer based on available help and expertise. To increase your chances of somebody being able to help you, please help us help you making sure you:

  • Adding an explanation of exactly what you're trying to achieve.
  • Adding any and all related code or previous attempts.
  • Describing the exact issue or error you are facing.
  • Posting any screenshots if applicable.
  • Reading through https://stackoverflow.com/help/how-to-ask.

When you're done with this thread, please close it. Thanks! ✨

(If you have a support agreement and need help, please contact the core team via email.)

safe canopy
#

can you show how you interact with the API? I know it's working and did this several times already. usually you can just log the result, regardless of the status code of the API within the next operation

short gazelle
#

Thank you for your response. Its just a simple flow. I have the API url, the method is get and as header i have to provide only Authorization. I tested this API call on next js and it's working. And as i said i'm new with Directus, I read the docs but i couldnt find something related to this.

#

I dont know if its possible to use the script part in the flow, I tried but i dont know if its possible to use fetch or axios to do it.

safe canopy
#

and what's within the activiy shown after the flow was run?

short gazelle
#

Thank you for having some patience with me. In flow log i get only error_log operation.

safe canopy
#

and what does it show?

short gazelle
#

just 'Error' because this is what i told it to show.
Now i made an express server and i get on payload this:
{
"name": "Error",
"message": "Requested URL "xxx" resolves to a denied IP address"
}

safe canopy
#

looks like the destination is blocked somehow

short gazelle
#

its a bit weird, they are both on the same server. i did a simple express server

short gazelle
#

On my first flow, the one in the image if i try to log {{$last}} i get an empty object. is there a way to log the error that the api request is giving back?

safe canopy
#

you can also check if there is something on the standard out of the directus app, depedning on the setup e.g docker logs etc.