How-to expose API with several output parameters
Application Type
Reactive

Hello all,

I am using OutSystems to expose an API method to get data about surveys and their questions.

I have a method where I pass the survey identifier and I want to get information about the survey (title, description, some dates, etc) and about their questions (question, question description, question type, and question multiple choice options).

This is the method:

And this is the JSON that I hope to achieve:

However, I get an error saying "Method can only have 1 output parameter when the Send In property is set to Body". Also, I understand that my JSON will not miraculously look like that, with the questions inside the survey.

Does anyone know how to achieve this? Thank you very much.

Solution

Hi,

I placed here an example, you need to adjust the structure as you need. You need to create a structure that support the questions inside the survey (something like this, you need to adjust the required fields):


Hope this can help.


Best regards,

Ricardo Pereira

Thank you very much Ricardo, this worked.

Hi!

I think that you can apply the same principles that the platform apply to services auto generated:


About the nested point, can you place here a picture or the definition of the structure that you're trying to use?

Thanks!


Best regards,

Ricardo Pereira

Hi,


You will need to create a structure. In that structure, you will need to have a Survey Record and a List of Question records:

Then, You will need define an output of the type of that structure:

Then, you will need to append the records from survey and the questions to that output.


Hope this can help.


Best regards,

Ricardo Pereira

Hello Ricardo, thank you. I have done that but the JSON doesn't look the way it should, with the questions nested inside the survey.

Questions is of data type surveys_Questions, and Surveys is of data type surveys_Surveys.

Then, I changed my output parameter to the structure:

And I appended them to the structure.

But the JSON is not nested:

Solution

Hi,

I placed here an example, you need to adjust the structure as you need. You need to create a structure that support the questions inside the survey (something like this, you need to adjust the required fields):


Hope this can help.


Best regards,

Ricardo Pereira

Thank you very much Ricardo, this worked.

Hi!

I think that you can apply the same principles that the platform apply to services auto generated:


About the nested point, can you place here a picture or the definition of the structure that you're trying to use?

Thanks!


Best regards,

Ricardo Pereira

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