How to make a list of all the objectNumbers out of a json file

Hello, 


I have a json file which contains 10 objectNumbers,

Is there a way I can make a list of all 10 so I can re-use them on another json call. 


Roelof


thanks, 


I hit another problem. I have 10 objectNumbers so there will be 10 times a output.

So I thought that I could use a list but I cannot make a list in the action.

Any hints ? 


I wanted to add my .oml file but I see several times a message that the .oml is a not valid extension 

hello


to post the oml you can zip it and provide the zip file.


the json should return the structure data type you selectedin deserialize.


so if you say you want a list of text, he should return you a that or an exception.


What do you mean you cannot make a list in an action?

hello, 


yes, the json de-serialize the json. 

What I mean is that I maked a server action  that calls the api, deserialize it 

then I made a loop where I did something with the first response but there I have after the loop ends 10 responses I want to store in a list. I use listAppend but first I have to have a empty list 

and in the server action I only can have input or output variables not local variables


I will include a zip of the .oml

Roelof Wobben wrote:

hello, 


yes, the json de-serialize the json. 

What I mean is that I maked a server action  that calls the api, deserialize it 

then I made a loop where I did something with the first response but there I have after the loop ends 10 responses I want to store in a list. I use listAppend but first I have to have a empty list 

and in the server action I only can have input or output variables not local variables


I will include a zip of the .oml

hmm what action are you talking about? i am pretty sure you can create a local variable in any action.

i even created a local variable in your action.


I think this is not a good first project. 


What I try to achieve is that on the second call some data is filtered out and there is a list of the filtered out data of 10 paintings

That one schould be be outputted so I can display things. 


But a lot of type errors. 



Hi.

In your output parameter (and for any variable), if you double click on the Data Type, if opens a window where you can define the Data Type and there you can choose a List of Objects of your choice.


hmm, 


I still do not get it totally I think

Is it possible that yopu let me see what you mean.

IM a little lost 

I changed the oml you provided, see if it makes sense to you

thanks, 


I makes sense, thanks

the only thing there is somewhere a bug. When I use this core module 

I see this as error : 


Failed to deserialize JSON to ArtObjectItem:
Unexpected character encountered while parsing value: S. Path '', line 0, position 0.


Maybe  I used the wrong approach or is outsystems not the right tool for what I try to achieve,


I have tried to ask here a while ago what I try to achieve : https://www.outsystems.com/forums/discussion/44092/can-i-easily-parse-this-json-and-filter-some-elements-out-of-it/


I want to ask a api for a repons. with the objectNumbers found in this json I have to ask two other api calls with another url to give me more info on the painting. Then I want to display some data on a gallery


I get what your problem is. You don't have a JSON, you are working with an API. 


You don't need the JSON_Serialize/Deserialize for what you are trying to accomplish. 

https://www.rijksmuseum.nl/api/nl/collection?key=14OGzuak&format=json&type=schilderij&toppieces=True

When you navigate to this url, you are making a GET request, which, in the browser, it is a JSON. Now, you use consume this this API in OutSystems, this JSON is mapped into a structure that you can compare it to a list. 

For what you are trying to accomplish, you can play with your API response as a regular list.

I recommend you to do this course which will give you more experience with web services overall https://www.outsystems.com/learn/courses/116/integrating-with-web-services/


Hello, 


Sorry for the late respons but I did that course before I tried my complex problem


What I tried to achieve is this :

1) API call to this url :    

 "https://www.rijksmuseum.nl/api/nl/collection?key=14OGzuak&format=json&type=schilderij&toppieces=True"


2) out of that json I need to have the objectNumber 

3)  another API call :  "https\://www.rijksmuseum.nl/api/nl/collection/NUMBER?key=14OGzuak&format=json" 

where Number is the objectNumber of one painting found. 

4) Last API call :     "https\://www.rijksmuseum.nl/api/nl/collection/NUMBER/tiles?key=14OGzuak&format=json"

the same. 


Roelof


Hi Roelof,

A was looking for some practice with REST API, so I played around a bit with your Rijksmuseum API.

See attached the oml, where I populate a list with the response of the first API call, and then, when a row in the list is clicked, retrieve extra information of any given object (the Description, which isn't in the response of the first call), with the second API call (didn't try the third)


One of the things I found, is that not all data retrieved can be parsed into the automatically generated structures, for example, the birthdate of an artist is in the structure as Date type, but sometimes this field in the JSON has a value of 1613, meaning I guess they don't know the exact date.  So you need to build some sort of error handling for these kinds of problems, or change the fields causing problems to a text format in the structure.  What I did is remove most of the fields and only keep the ones I'm actually using, to avoid most of the parsing problems.


Hope this helps you on the way,

Dorine


Dorinne, 


Thanks.  I will study your example and will try to build something I had in mind.

More a galllery idea

@Dorine, 


Can you take a look at my .oml file..I tried to add a url which later can be a image to it and now the site chrashed,

Any idea what I have done wrong ?

Hi Roelof,


the cause of the 'crash' was that you added the GetCollectionDetails REST call at the end of the Preparation.  Don't know what the purpose is of that ??  No need for retrieving the URL, that is already in the output of the first API call, so that is available as 

CollectionTableRecords.List.Current.Url

The reason it crashed, is that there was no NUMBER passed into it (at end of Preparation the screen local variable Details.ObjectNumber is equal to NullIdentifier.


If you feel like you need to get extra info for each item in your list immediately when retrieving the list (which will make for a slow opening of your screen) then you should look at doing this in a loop inside your server action. See my example, where a ShowDescription flag passed into the Server Action, will retrieve the description, which is not available in the output of the first API call, by calling the GetCollectionDetails for each item looped over.


Attached a new OML, with the image + link in the table, and the option to retrieve descriptions immediately, have a try and see how much slower that already is, for just 12 items in the list.

Thanks, 

I see that it is slow. 

Im tryimng to figure out how I can make this work with the image gallery page and I think I need some time to figure some things out


I was thinking about doing this a certain way but it seems I thought a another path or this is a too difficult problem after doing the web developer course. 


but again many thanks for all you have shown me. 


Roelof