POST /ws/rest/v1/billing/billableService fails in Postman but works via OpenMRS UI

Hi folks,

I’m trying to create a new BillableService via the REST API (/ws/rest/v1/billing/billableService) on dev3.openmrs.org using it as a working example.

When I POST the following payload via Postman:

{
  "name": "red",
  "shortName": "ed",
  "serviceType": "1592AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
  "servicePrices": [
    {
      "paymentMode": "526bf278-ba81-4436-b867-c2f6641d060a",
      "name": "Cash",
      "price": 1.06
    }
  ],
  "serviceStatus": "ENABLED",
  "concept": "140509AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}

I get this error:

"error": {
    "message": "[servicePrices on class org.openmrs.module.billing.api.model.BillableService => Cannot invoke \"java.util.Collection.toArray()\" because \"c\" is null]",
    "code": "org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource:692",
    "detail": "org.openmrs.module.webservices.rest.web.response.ConversionException: servicePrices on class org.openmrs.module.billing.api.model.BillableService..."
}

with full json log here → { "error": { "message": "[servicePrices on class org.openmrs.modul - Pastebin.com

However, if I create the same service via the OpenMRS web UI, it succeeds, and the servicePrices are populated correctly and checking the request payload it is the same as i use for postman.

Has anyone been able to POST a BillableService successfully using Postman? Any working example payloads into why the REST throws an Exception here would be appreciated.

cc @ibacher @tendomart

@jonathan let me try and see

1 Like

@tendomart Just found the solution thanks to @senthilathiban basically for anyone who may face the same

Use POST /ws/rest/v1/billing/api/billable-service for creating a billableService and GET /ws/rest/v1/billing/billableService to return a list of billableServices

2 Likes

Awesome thanks for the feedback