Skip to main content
Solved

API function that returns JSON


Freddy
Forum|alt.badge.img+16
  • Thinkwise Local Partner Brasil
  • 528 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\"}]"
}

 

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.

View original
Did this topic help you find an answer to your question?
This topic has been closed for comments

2 replies

Anne Buit
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 637 replies
  • 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
  • 528 replies
  • April 21, 2023
Anne Buit wrote:

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. 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings