Hello everyone, I am trying to make a POST call to a public API and try to read the response. I have gone through the blog - How do I call my API from an Action? - Auth0 Community that explained how to make a call to Auth0 protected API.
However, In my case, the API I am trying to call is a public API. I am not getting any response from the API, nor any error; when running the action.
I have tried calling the API via Postman as well as from c# code and it returns the response successfully each time without any error.
I understand your Action script is not returning any response.
After looking through your code, I noticed that the data you are passing seems to be literal strings, namely âusernameâ and âpasswordâ. In this case, I suggest that you store the data as Action Secrets.
Besides that, I did not find anything that stands out to be an issue. However, I suggest that you check whether your API request requires more than just supplying the data, such as defining the headers.
I would strongly suggest following this skeleton for making API calls with Axios:
Alternatively, you could export the Axios code using Postman and implement it that way into your Action script. To do so, click on the Code Snippet icon located on the right column of the application. Then clicking on the drop-down menu, select NodeJs -Axios. See below:
I tried with the skeleton you provided for making API calls with Axios and also tried with the code generated from Postman. However I still donât see any response or error in the console log.
Following is my updated code snippet for your reference.
Hello Everyone,
I noticed that, my Action/Rule is displaying the logs only in âReal-time Webtask Logsâ. It does not working if I attach to a flow or run with âTestâ button.
Anyone from this community facing the same issue calling an API from Action/Rule?
Any help in this regard will be greatly appreciated.
Note that we need to save the response as a variable and await for the Axios post result before storing it as a custom claim in the token. If we do not wait for the response, we would observe undefined custom claims or claims that do not get appended to the token.
Hoped this helps!
Please let me know if thereâs anything else I can do to help.