0

I used the micro profile to make a call to a specific API, it happens that this call gives me a list of URLs and I have to make a call for each URL returned.

My objective is call all of these URL e verify HTTP status returned.

"ApiResources": [
                    {
                        "ApiFamilyType": "products-services",
                        "ApiVersion": 1,
                        "ApiResourceId": "d33ff8af-5a1b-4b43-90d4-34237997d080",
                        "ApiDiscoveryEndpoints": [
                            {
                                "ApiEndpoint": "https://api.yyyyyyyy/v1/personal-accounts"
                            },
                            {
                                "ApiEndpoint": "https://api.xxxxxxx/business-accounts"
                            }
                    }
]
ZygD
  • 22,092
  • 39
  • 79
  • 102
Alex Braz
  • 1
  • 1
  • Hello Alex. If you could provide some basic details: What you are trying to accomplish, what you've tried, post any errors you received, and post a minimally reproducible example or more of your source, I'm sure someone would be more equipped and able to assist you – Paul Stoner Aug 26 '21 at 19:45
  • Hello Paul, tks for your answer. In my implementation im already obtained the response correctly, as part of the response i receive some dynamic urls, i need to call these urls to obtain http status of all. Thats my problem, how can i call these urls receive as response of rest client? – Alex Braz Aug 26 '21 at 20:04
  • Hi, you basically need to parse the response and call the endpoints you get one by one. That is not really Quarkus specific as you can use and HTTP client to make the calls – geoand Aug 27 '21 at 06:11
  • I'd add that the MicroProfile RestClient is not suitable for this scenario where you want to send requests to arbitrary URLs. But if you have MicroProfile RestClient, you also already have JAX-RS Client, which can do the work just fine. Search for "JAX-RS Client", you'll find plenty of examples. – Ladicek Aug 27 '21 at 07:41
  • if you are looking for somehting like a health check on your APIs, you can use the https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-5.0 or this blog here https://blog.zhaytam.com/2020/04/30/health-checks-aspnetcore/ – thanzeel Aug 27 '21 at 11:18
  • All the comments thus far provide some excellent examples of potential solutions. I would also add to @geoand comment to simply loop over each string value and fire of a request. This would provide a sequential method. Or you could parse each url to a separate variable and fire them off in individual threads if the order does not matter. I would do either method in an asynchronous manner incase one of the calls takes a long time to return. – Paul Stoner Aug 27 '21 at 13:34

0 Answers0