Hello,
I have set up a REST API with OutSystems which has an endpoint that receives parameters and a body. Depending on the parameters, the body is written to a file in a different folder on our file system. This works smoothly when receiving only a single request, but when our user sends multiple requests at once (not sequentially, all at the exact same time), only the first request gets handled and the other two are not treated at all.
I've looked for solutions, but I haven't been able to find anything on this.
Thanks in advance!
Hi Anton,
what do you mean when you say "not treated", what is the cause ? Is the problem in the platform, or in your logic of handling them ? Can you tell something more of what you see ?
For example, when looking in Service Center on the integration tab, how many requests do you see arriving ?
Dorine
Hi Anton,What is mean by user sends multiple requests?Do you receive multiple files in a single body i.e. single call?Did you find any errors in the service center?Regards,Nagesh
When you expose a REST API, its methods can be called (from the outside world) in parallel, and they are processed in parallel (both the same method and different methods).
From your description, it is very unclear what exactly happens. Check the Integration Log (like Dorine suggested) to see the requests received, but also, what happens in the calling software? Do they get an HTTP error (like "500 Internal Server Error") or is there a timeout? Are any errors showing in the Error Log?
You say you've "looked for solutions", but please first start with the problem; it seems you haven't got clear what the actual problem is at all!
I've checked the logs and the logs only indicate that there has only been one request made at that time.
For example: The user sends two requests at the same time (they press a single button that sends the requests, because that's easier APPARENTLY) and we get two requests with an id and a body.
In the logs only the first request of the two is logged and only the file for the first request is made. The second request just vanishes as if it wasn't sent at all. However, the second request does get a 200 OK response.
So I'm completely stumped at what is happening at this point and the user is very adamant on using their button to send multiple requests instead of sending them one by one with about 500ms delay. Funnily enough, the have been instances of up to three requests being processed within the same second, but it just seems that the requests being sent at the exact same time is giving problems.Kind regards,
Anton
Hi Anton,You mentioned that, "In the logs only the first request of the two is logged" and also "However, the second request does get a 200 OK response". Here, how did you get to know about 200 OK response?Also, to get closer to that root cause, use "LogMessage" action - Outsystems system action. Print detailed timestamps of the immediate multiple clicks. This will help to analyse the issue ahead.Regards,Nagesh
You're sure they are actually doing 2 requests, and not 2 sets of data in 1 request? Because unless they implemented some parallel processing the 2 requests they send will be sequential.
I'm not sure exactly, but at the least they're not just meshing two request bodies in one. And I don't think of a way that there could be two separate request bodies in a single request. I did ask them to be sure a couple hours ago, but I haven't received a reply yet because of timezone differences.
I think you need some sort of proof that there are actually 2 requests.
Also, who is "they", and are they sending requests directly to your rest api url, or is there some sort of api middelware between that could possibly be causing this ?
I'm using Outsystems in a work-related context, "they" are an external company that I set up integrations with. The API is custom made for them as it needed very specific things and they're sending it immediately to us.
I have since heard that they're sending the requests simultaneously because of concurrency control, but I'm failing to see why this would matter for us as we (our IT department) don't care about duplicate requests (we already have checks for these).
I'm also sure that they don't append the bodies to each other as I would have been able to see this in the files that are made and I would be able to separate those either manually or programatically.
I'll check Alexandre Yip's suggestion to log more details to dig further into this.
ok,
you have proof in the logs that you only get one request, so now it is up to them to prove that they actually did more than one, I haven't seen that yet in your comments, them just saying that is not enough.
Do they have logs showing they really did invoke your api url more than once ???
in the meantime, it could not hurt if you would build some test facility on your end trying to mimic the exact calls they make, and see (even debug) what is happening.
Although, I don't know how you could make them "simultanous" as you call it, just very close together.
That is in fact a problem yes, because calls very close together are handled well, only the simultaneous ones have this problem.
The external company did show us logs from them getting 200 OK confirmations from our API, on all requests they sent simultaneously. I'm working right now to implement a change so instead of just 200 OK confirmations, I'm adding identifiable information about the request body so we can confirm if Outsystems is handling all requests and just not producing the files for the requests past the first, but still sending the confirmations to all requests, or if Outsystems only handled the first request and then sent confirmations to all requests, even though the ones past the first weren't even processed.
keep us informed if you will of your progress.
but just out of curiosity, what is meant by simultanous, how do they do that, and how is that different from one directly after the other ???
That's exactly my question. Sending "simultaneous" requests takes effort to get that working. And I don't see the added value on their side of spending that time for something that doesn't offer any benefits.
That's also what I was thinking, but alas I'm stuck in this situation now and all the integration work is already done for the project. This is the only issue left. I once again asked the local team to ask what exactly they're doing since I don't speak the language of the external company and they are not proficient in English.
Hi Anton Engels,
Add to your REST
OnBeforeRequest
OnAfterResponse
callback actions and log there json details from the request / response
https://success.outsystems.com/documentation/11/extensibility_and_integration/rest/consume_rest_apis/simple_customizations/
you can check also integrations tab on service center monitoring
https://success.outsystems.com/documentation/11/extensibility_and_integration/set_the_logging_level_of_rest_and_soap_integrations/logging_levels_reference_for_integrations/
Hope that it helps you
@Anton Engels this seems to be the first approach to go.
You can use the OnBeforeRequest, serializing the the request Body as JSON and then log it to Service Center (throughout LogMessage). Be aware that Service Center parse the log after an amount of characters.
Nelson
Parallel API calls should work perfectly fine. Only one thing as you mentioned that "the body is written to a file in a different folder on our file system" . You need to check whether the File that in which you are writing should not be same. Otherwise it would give you exception the file is used by some another process.
Regards
Devendra