Is there a way to handle the error code "protocol.http.InvalidPath" more gracefully ?

We have noticed that when we add certain special characters in url paths like this:

https://<host alias>/v1/some[]ids/resource

Apigee is unable to route this to our API Proxies and instead returns 400 Bad Request with the below error message to the clients.

{"fault":{"faultstring":"Invalid path GET \/some[]ids\/resource HTTP\/1.1","detail":{"errorcode":"protocol.http.InvalidPath"}}}

We would like to have these kind of requests routed to a Proxy named "InvalidRequestsAPIProxy", but these requests are not hitting this proxy.

Is there some way we can handle these kind of requests more gracefully ?

0 2 1,364
2 REPLIES 2

The error protocol.http.InvalidPath is thrown by Message Processor as it checks for special characters such as "[", "]" etc in the path at an early stage even before it starts executing any policy.

One possible way to avoid this error is for THE CLIENT to use encoding for these special characters:

For ex: https://<host alias>/v1/some%5B%5Dids/resource

Note: %5B is the encoding for [ and %5D for ]

However, if the clients do pass these special characters as part of the request without encoding them, then there's no way to route to different Proxy or throw a different error message currently.

I'm getting this error WITH encoded brackets in path, whereas other special characters don't get this error.

Edit: I opened a new question here with more details