Solved

API function that returns JSON

  • 20 April 2023
  • 2 replies
  • 70 views

Userlevel 5
Badge +16
  • Thinkwise Local Partner Brasil
  • 387 replies

Hi. How can I achieve an API function that will return full JSON. 

Now I get the oData value property, but its content is not in JSON and in the external component there is no way to transform it to proper JSON. 

{
"@odata.context": "https://dev.esm.app.br/indicium/sf/esm_dev/$metadata#ESM.subroutineScalarResult",
"value": "[{\"org_id\":2,\"org_name\":\"LEF\"},{\"org_id\":10,\"org_name\":\"Servicedesk\"},{\"org_id\":11,\"org_name\":\"Sistemas\"},{\"org_id\":13,\"org_name\":\"Contratação\"},{\"org_id\":16,\"org_name\":\"Change Manager\"}]"
}

 

icon

Best answer by Anne Buit 21 April 2023, 09:55

View original

This topic has been closed for comments

2 replies

Userlevel 7
Badge +5

Hi Freddy,

Is it an option to expose a table-valued function with as API instead of a scalar function? A returned text value of a scalar function can be anything, Indicium does not recognise it to be json and simply escapes the value to be used in the json response.

If i'm not mistaken the a returned table of a table-valued function exposed as an API renders as proper json.

Userlevel 5
Badge +16

Hi Freddy,

Is it an option to expose a table-valued function with as API instead of a scalar function? A returned text value of a scalar function can be anything, Indicium does not recognise it to be json and simply escapes the value to be used in the json response.

If i'm not mistaken the a returned table of a table-valued function exposed as an API renders as proper json.

Yes the TVF works differently..  in this case I altered an existing view with the missing info.. instead of a function, I can ofcourse also use the $filter function of oData to get the set I want.