mulemule-studioendpointanypoint-studioapikit

Mule ApiKit - Endpoints for ../api/items and ../api/items/{itemId} at the same time?


In mule how can we serve endpoints for ../api/items and ../api/items/{itemId} at the same time ?

I was wondering how to make the ApiKit work for the endpoints.. I get nullpayload and an exeption when I call ../api/items which was exactly defined in https://support.mulesoft.com/s/article/ka434000000TPOz/Method-not-Allowed-on-API-Kit-requests

But there the solution mentioned is not practically applicable


Solution

  • I resolved it just adding a groovy script before APIkit Router .

    It is

    import org.mule.api.transport.PropertyScope
    
    if(message.getInboundProperty('http.request.path') == '/api/items') 
        message.setProperty('http.request.path', '/api/items/*', PropertyScope.INBOUND)`
    

    And when I see a star * as the item id I behave accordingly in the flow implementation