0

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

mcvkr
  • 3,209
  • 6
  • 38
  • 63

2 Answers2

0

In raml both of this endpoint are valid. You can use this there is no problem for that.

Abani Patra
  • 172
  • 3
  • 12
  • I was wondering how to make the ApiKit work for the endpoints.. I get nullpayload and an exeption when I call ../api/items , ../api/items/{itemId} works fine – mcvkr Feb 19 '17 at 19:18
0

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

mcvkr
  • 3,209
  • 6
  • 38
  • 63