warpscript: WEBCALL success or fail

67 Views Asked by At

I want to use WEBCALL. I have the following question:

How to know if the WEBCALL is ended with success or fail?

Thanks for you help!

1

There are 1 best solutions below

1
On

You cannot get the result back of a WEBCALL and this is the topic of an opened issue (https://github.com/senx/warp10-platform/issues/697).

To summarize the issue discussion, WEBCALL is asynchronous and queries may be done by another server in the case of a distributed setup. So this complicates a lot the process of getting back the result, which includes the potential failure of the request.

If you don't mind doing synchronous requests and being limited to GET, you can use URLFETCH (https://www.warp10.io/content/03_Documentation/07_Extending_Warp_10/10_Native_Extensions/07_URLFETCH_Extension). Here is a quick example on how to use it:

'YOUR_READ_TOKEN' AUTHENTICATE

'https://postman-echo.com/get?foo1=bar1&foo2=bar2'
{ 'custom-header' 'some value' }
URLFETCH

0 GET // Result from the only request
'result' STORE

// Decode the payload
$result 3 GET
B64-> 'UTF-8' BYTES-> JSON->
'json_payload' STORE

// Update result with decoded payload
$result $json_payload 3 SET