Hello
I am trying to log the errors of a consumed rest API. This error logging consists of 2 things:
1) I need the input which goes into the rest-API to mark which record failed
2) I need the output of the rest-API to see what errors occurred during an action.
The error mapping should work but I cannot combine these both.
--
It is NOT possible to change the consumed API's inner working.
What have I tried?
1) I considered with an exception handler but it will just just throw me in the exception handler so it will forget the input parameters... Where the Input info will be stored.
2) I tried with the onafterresponse of the API but it also will forget the input parameters.
Is there anything I should take a look at?
Hey
first of all thanks for the help already!
I think there was a misunderstanding all of this needed to be fully automatic and it would need to create records without human interaction. I found a way to achieve this by getting the logs from the platformlogs extension. Would you consider this as a viable option?
Hi Simon,
You activate the logs for a given API and all the calls made from that API are going to be full logs are going to be automatically logged by the platform.
Which part of this seems manual, other than obviously you need to turn on the logs once for the APIs you want, that it doesn't work for you because "all of this needed to be fully automatic"?
The way of accessing that data, you already have it built for you and accessible via Service Center as I have shown it to you. If you want to build a specific app for different users and different interface or logic on it, you would have to build it, reading the data from the platform's metadata.
Cheers,João
You can turn on the logging level to full. By doing so, that REST API consumed call will have the full logs of the input Path, body and values and the same for the output.
Check this forum post which explains step by step how to do it.
Kind Regards,João
Hey Joao
Looking promising but how can I access these logs programatically?
It's all in there, step by step, on the link I sent you:
I see but where Can I access these in Service Studio. I can see how I can access them from Service Center
Going through the instructions, step by step:
1. Access Service Center and navigate to Monitoring - Integrations
2. Optionally filter by the module that consumed the API:
3. Click Detail or Error icon in the last column (it will only appear on the calls you consume after you have activated the Full log):
4. You get all the details of the request and the reponse, having the possibility to extract it all in a document via the Download HTTP trace button:
The last part was what I was missing :)
This part needed to be automated and customized to certain requirements. Only thing I will need to do know if map the log to our error codes! Thanks Joao!
Hello Simon,
You can call consumed API inside a server side action and you can save inputs to a database entity first as single values into different columns or as json into a single text column and keep Id of created record until you get response from API and update same record with output json of API and also you can add column as status flag for example in case success save its value as true and in case failure save its value as false
Hey mostafa
Problem is that I am afraid that the input & the output are not connected by any variable... The only way it is possible to connect them is through the same session. I would not be able to link the output to the entity record that was made by the input. I only get back an error message. For example
{
message: "Failed to perform action"
"Errors": Field X did not pass validation
}
As per sample you add I can see in case error into API its return some kind of response which you will need to handle into your action by adding error structure for example to response body of API . If API return error code execution will jump to exception handler and you still has value of your action input or local parameters and save exception message.
Hi Guys,
To log the error output of a REST API, use a robust logging framework like Log4j or Winston in your code. Capture API error responses and log them with appropriate severity levels to aid debugging. Ensure that sensitive information is not exposed in logs to maintain data security and privacy. Regularly review and rotate log files to manage storage efficiently.