42
Views
5
Comments
Solved
Output structured data from extension

Is it possible to make the output of a custom extension a structure? For example, let's say I'm using some C# to make an API call to some service, and I want to have the output of that API call already in its standard structured JSON format as defined inside the C# project. Is it possible to make that the output instead of outputting it as text, and then deserializing it in the server action? Would it need to be a record type for the parameter? Does anyone know of any forge components that demonstrate this?

2018-12-01 17-54-01
Sourav Pasari
Solution

When you define the method in integration studio set the output parameter as ->

  record list of structure

It will create a Out param of List<Structure> in C# code

2018-12-01 17-54-01
Sourav Pasari

Hi,

1. You can create a structure in the extension which will be having the same attributes present in your json output from API. 

2. Now this structure will be available in your .net extension library

3. In your .net function where you are getting the json value from the API, there you can make the return type as List<newstructure>

4. Parse the JSON and fill up the list (type of newstructure) and return.

2022-11-14 17-25-57
Daniel Johnson

What is the output parameter type in this suggestion?

2018-12-01 17-54-01
Sourav Pasari
Solution

When you define the method in integration studio set the output parameter as ->

  record list of structure

It will create a Out param of List<Structure> in C# code

2022-11-14 17-25-57
Daniel Johnson

What's the difference between record and record list? If the API is known to always only return a single object, like: {"name": "Elon Musk", "role": "CEO", "age": 52} does it still have to be a record list even though it's one object?

2019-01-07 16-04-16
Siya
 
MVP

If you know you will always return a single object, you can keep the output as a Record, not a Record List. Calling the API and processing the result are part of the implementation within your code.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.