Unable to use webhook output

(victor) #1

Dear community,

kindly assist i am unable to consume an output from from an API call using webhook.

this is the log message from flowxo attached below

please how do i access the error tabs logs. want to access the message.statusCode or the message.message output

but normally from flowxo you this below

image

then you can access the statuscode or body or data depending but i am getting the error from pix 1 above

(Nathan Stults) #2

Victor,

The HTTP task, when it receives a 500 error, considers the entire request a failure and you can no longer access the response code or any other aspect of the response, because the flow is in a failed state.

You have two choices:

  1. Use a Code block to make your request ( see our docs on the Code block, there is an example of making a request) and then you can handle the output however you want
  2. Have the web service you are calling return a 200 OK response, and put the true error code / error message in JSON that you can read from the flow.

Nathan

(victor) #3

thank you @nathan.

i actually used the code block; see my code below but i still dont get response.

and these are my inputs i received from the object

i actually need the response of that status code of 500 cos thats when i get the result

(Nathan Stults) #4

That screenshot shows you using a Code block to try to respond to the results of the HTTP request, but to get the status, you’ll also need to use a code block to make the HTTP request in the first place (you will NOT use an HTTP action).

Here’s an example: https://flowxo.com/share/vr2gyym3

(victor) #5

thank you so much @nathan.

However, what do you think could be the best filter condition to make this code block run. cos i am interested in using the 500 error response message in order to output a response.

i am building a kind of API monitoring system within the bot that monitors the API failures

(Nathan Stults) #6

I’m not sure exactly what you’re asking, but I updated the sample to send various replies based on the status code:

(victor) #7

thank you so much @nathan.

you nipped it with the last answer.

what a great help you are to the community.

God bless you

(Nathan Stults) #8

No problem, happy to help.

Nathan

(victor) #9

Dear @nathan,
its victor again. so sorry to bother you.
but upon making a GET request on the APi it seems some security issues with our firm.

However i can make a POST request but i am still getting error response of subscription key not found.

find Screenshot below
image

although i have twerked removing the hyphens but same issue.

please assist

(Nathan Stults) #10

We make the Request library available to you. When you do utils.request, you’re simply accessing the Request library directly, so you’ll want to research how to set HTTP headers using that library, because you can’t just include them directly in the options:

Nathan

(victor) #11

Thanks @nathan,

The resource was a great insight but the intereaction keeps giving me error response.
see code below

but i keep getting error from the interaction log like so;
image

have checked my script and syntax. it seems to be okay.
please use your wisdom and insight to assist

(Nathan Stults) #12

I’m not sure what’s wrong with your code exactly that produces that error, but I can say that this line:

body: {
paramx: 2,
msisdn: {{variable}},
}

probably doesn’t work unless that variable is a number. It would be better to use the Inputs mechanism (see how I did url) to send the variable into the code.

Otherwise I’m not sure - your best bet is to get the code running in the nodejs commandline, or use Visual Studio code or some other JavaScript environment where you can debug properly, then when you get it working copy it into the Flow XO code block.