How to avoid apigee changing the incoming url?
when the incoming url has some empty path params , apigee automatically strips the empty path param and changes the incoming url .
eg: For a sample url as below
https://apigeedomain/path1/{pathParam1}/path2/{pathparam2}/path3
if the incoming request url has emptyParam 'pathparam2' like below
https://apigeedomain/path1/abc/path2//path3
Apigee automatically converts the incoming url as below stripping the empty pathparams
https://apigeedomain/path1/abc/path2/path3
Welcome to the community !!!
First of all, I think this is not good REST design. Ideally you should not accept those params to be null. Path parameters are the unique identifier of a resource. In your case to get to pathparam2, it should be part of the hierarchy. Think of them as directories (or folders). Without knowing Folder 1, you cannot access Folder 1.1 and without knowing 1.1, you cannot access 1.1.1 But as per your request you are trying to access 1.1.1 without telling that the parent is 1.1. More info here
Probably you can do is replace the null with a wildcard search /path1/abc/path2/*/path3 or use query parameters or include a new endpoint called /search that can return those resource
Thanks for your comment Sai. Our application does not accept empty pathparams and it will give a 404 Request Not Found error, But when it is routed via apigee, Apigee automatically strips the empty pathparam in the url and changes the url and sends to our application and our application treats it as a different endpoint
Say for eg ,our application exposes the following endpoints
ListInvoiceTemplate :
HTTP GET : /v1/users/{user_id}/invoices/{invoice_id}/template
GetInvoiceDetails:
HTTP GET : /v1/users/{user_id}/invoices/{invoice_id}
when Apigee gets the incoming request for ListInvoiceTemplate with an empty invoice_id
HTTP GET : /v1/users/{user_id}/invoices//template
Apigee automatically strips the empty Path param and send to our application as below
HTTP GET : /v1/users/{user_id}/invoices/template
Our application treats this as GetInvoiceDetails request thinking template as invoice_id as its a dynamic path param and will return a different response.
Apigee should send the incoming request as it gets to our application.
HTTP GET : /v1/users/{user_id}/invoices//template
How to fix/avoid this scenario.