Original Message:
Sent: Thu September 14, 2023 01:28 PM
From: pratap vadlapati
Subject: Custom Error in UnauthorizedError in API Connect
Hi Steve,
I couldn't find the logs yet,
ideally we need to capture
ConnectionError
- UnauthorizedError
- BadRequestError
- ForbiddenError
Do we need to use trow action in API assembly to invoke Global-error-policy ? if yes how will be able to handle 400 params missing error(as below), Bcoz it not available in assembly to throw.
{
"httpCode": "400",
"httpMesage": "Bad Request",
"moreInfo": "One or more required API paramenters are missing in the API request"
}
------------------------------
pratap vadlapati
Original Message:
Sent: Tue September 12, 2023 11:02 AM
From: Steve Linn
Subject: Custom Error in UnauthorizedError in API Connect
Hi Pratap,
Is this the case for the Connection and SOAP Errors too, or just the UnauthorizedError for example? There is an open issue for OAuth API requests that OAuth errors of any type are not caught by the global post-error policy. I'd suggest enabling debug logging on your DataPower apiconnect domain, run a transaction, and then you should be able to (tediously) follow the many logs and match up with the assembly flow to find the error and the invocation (or non-invocation) of the post-error catch logic. If OAuth related, you should open a PMR.
Best Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Tue September 12, 2023 05:19 AM
From: pratap vadlapati
Subject: Custom Error in UnauthorizedError in API Connect
HI Steve,
we are trying to send custom error in Apic v10, so we used error global policy, but the catch is not triggering. But I can see the config in Datapower API Collections main rule catch.
I don't see any errors related to policy or xslt . this xslt is working in the assembly if i put throw action and define catch with the same xslt.
As of now now its configred with error global policy, but we get the default apic error from api, instead of gloabl error policy error.
global-policy: 1.0.0
info:
name: sample-error-policy
title: Sample Error Policy
version: 2.0.0
gateways:
- datapower-api-gateway
assembly:
catch:
- errors:
- ConnectionError
- UnauthorizedError
- BadRequestError
- ForbiddenError
- SOAPError
execute:
- xslt:
version: 2.0.0
title: xslt
input: true
source: >-
<! Sime xslt to send custom message based on the error codes>
------------------------------
pratap vadlapati
Original Message:
Sent: Mon November 28, 2022 10:25 AM
From: Steve Linn
Subject: Custom Error in UnauthorizedError in API Connect
Hi Oscar,
This would need to be done in a post error global policy. Where is the catch that you referenced above?
Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Mon November 21, 2022 03:59 PM
From: Oscar Gonzalez
Subject: Custom Error in UnauthorizedError in API Connect
Hello. API Connect 10 lovers.
I need customize Errors when unautherized client access. But In the documentation Error cases supported by assembly catches is not supported UnauthorizedError, I tried to capture, but without success.
In catch I tried this.
catch:
- errors:
- UnauthorizedError
execute:
- gatewayscript:
..... some code ...
context.message.header.set('Content-Type', "application/json");
context.message.body.write(json);
------------------------------
Oscar Gonzalez
------------------------------