More that one api request in the same server action is not working
Question

Hi, I am building a service for Reactive Web App. I am using 3 api request in the same server action:(each getaction has api request inside for data)

for example :

When I run the program in debug everything works fine. But when i run it without debugging i get an error

I think that the problem is that some of the api requests takes some time and the programm keeps running without all of the data returning. When I use debug, the time factor is not an issue. If that is the problem(not sure), how should you use more than one api request in the same action, is there a way to do that? 

Thank u very much in advance, Roy

Hi  roy mainfeld,

The default server action in OutSystems is 10 secs ( you can also overwrite this server request time out)

but as I understood in your case when you call the first API inside the server action, Here server action get time out after 10secs,  in that 10 secs maybe you won receive a response from the API, 


immediately after the first API call you are calling the second API in the server action with inputs of the First API response, since the first call gets time out so there is no response, so the second API call throws error


so the solution is to try to overwrite the default server action time out if your API takes too long to response


Another solution: you can use the data action in the screes and call the API inside the data action and then you can increase server request time out just for that data action instead of module server request time out 

I hope this helps you 




Hello Roy,

The API is returning values that are being used in the next API?

401 Unauthorized client error status response code indicates that the request has not been applied because it lacks valid authentication credentials for the target resource, the credential is valid or is present on the moment you call the API?


Provably not your issue but just something to check. Some services have rate limiting applied on their API so if you have a loop that is calling an API a lot of times very rapidly the other end may be throwing an error after a certain number.

From your image looks like you are talking to Zoho?, quick google shows that they do have rate limits on some of their API's although the error would probably be a 429 rather than a 401 so may not be the issue,

Zoho Desk API - Rate Limits?

 

The API is returning values that are being used in the next API indeed. I solved it with a sleep forge component(between the getTags and GetTasks i sleep for 0.5 second). I believe its not the best solution. I am trying to understand how to make this rest api requests async and wait for the response before I continue the flow. I realized that maybe BPT can help me get there with auotomatic activities but each automatic activity cant return as an output param the response structure of the api.

Does anybody know how to force those requests to be async?

Thank u very much in advance, Roy

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.