Skip to main content
Answer

API function that returns JSON

  • April 20, 2023
  • 2 replies
  • 86 views

Freddy
Forum|alt.badge.img+16
  • Thinkwise Local Partner Brasil

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\"}]"
}

 

Best answer by Anne Buit

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.

This topic has been closed for replies.

2 replies

Anne Buit
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • Answer
  • April 21, 2023

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.


Freddy
Forum|alt.badge.img+16
  • Author
  • Thinkwise Local Partner Brasil
  • April 21, 2023

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.