cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 API - change returning JSON key

Magento 2 API - change returning JSON key

If any one come across this issue...

 

I have created custom API with Magento that will be consumed by 3rd party system, which expect fix formate of API response. I have created API data interface and I could able to get formate what they need, but facing problem with JSON associated that API returns,

 

Magento by default changing getter method name into SnakeCase, i.e I have

public function getInvoiceUrl();

this will return

{
  "invoice_url": "string"
}

But my expected output is UpperCamelCase like

{
  "InvoiceUrl": "string"
}

how can I achieve this with API data interface??

As returning API data with array will return response like,

[{
    "InvoiceUrl": "string"
}]

Regards