Search code examples
azureazure-logic-appsazure-api-management

APIM Request URL Optional Path


I'm using APIM to ingest data from an external service (pointing to a Logic app HTTP request of course, using POST method). The service has dynamic URLs that are passed to my APIM API continuously in a loop.

For instance it will send me a dynamic URL such as baseurl/one then baseurl/one/two, all in one loop that it tries to pass to my APIM.

The issue is that the APIM front end does not accept optional parameters to the template parameters (baseurl/{one}/{two}). They have to be required. I tried opening in OpenAPI editor and when I set the parameter to false. It tells me it only allows me to set to be true.

enter image description here enter image description here

So when APIM sees the baseurl/one, it errors the service because APIM requires the{two} parameter. Is there a way via policy to have APIM ignore the {two} optional parameter?

I have tried using the <path segment="/optionalPath" /> inside a condition to check the URL segment length, but APIM doesn't allow it apparently. Or even check if {par2} is set then require it otherwise just use {one}?


Solution

  • The issue is that the APIM front end does not accept optional parameters to the template parameters (baseurl/{one}/{two}). They have to be required. I tried opening in OpenAPI editor and when I set the parameter to false. It tells me it only allows me to set to be true.

    Yes, template/path parameters are required and AFAIK, we can't define them as optional in APIM.

    enter image description here

    Either you can take the parameters as Query parameter to accept the value optionally with the help of Required checkbox.

    enter image description here

    Or you can add them as a separate operations like below.

    Added the API-

    enter image description here

    Then added all the Operations in it-

    enter image description here

    enter image description here