Hi,
I have datasources script in python which runs fine and also I can see the element also got created, but when I click on that element it shows that no visible data pages available.
in http://localhost:34567/swagger/index.html when test on api/parameters I see that I get "Sequence contains no element" what can be the reason?
Hi Apurva,
With DataAPI, an array symbolizes a table. If you have an array inside another array, we try to create a linked table with a foreign key relationship. This means that the "ServiceInvolved" property in your JSON would be a linked table, but because it does not have a key-value pair structure, it fails to resolve the parameter structure.
I did a quick local test and with your JSON I got the same error but if I adapt it not to include the "ServiceInvolved" property
{
"components": [{
"AlarmId": 3614501,
"ElementId": 290,
"ElementName": "Sky-News-TXCore",
"Severity": "Critical",
"ParameterDescription": "Memory Usage (Servers Info) sky-news-pi-ams",
"ParameterValue": "70.000000",
"StartTime": "/Date(1736263098000)/",
"ClusterName": "Contribution"
}, {
"AlarmId": 3614481,
"ElementId": 312,
"ElementName": "MUN-X20-FRM-003_1_2_4_19",
"Severity": "Critical",
"ParameterDescription": "Signal Loss (Decoder Services) 3/Auto First Service [239.202.1.4:5000] 3G-1BD",
"ParameterValue": "BLACK_FRAME",
"StartTime": "/Date(1736262135000)/",
"ClusterName": "Contribution"
}
] }
I get it to work with the following result
If you still want to keep the "ServiceInvolved" property I would suggest adapting the structure to be something more like
{
"components": [{
"AlarmId": 3614501,
"ElementId": 290,
"ElementName": "Sky-News-TXCore",
"Severity": "Critical",
"ParameterDescription": "Memory Usage (Servers Info) sky-news-pi-ams",
"ParameterValue": "70.000000",
"StartTime": "/Date(1736263098000)/",
"ServiceInvolved": "TX Core",
"ClusterName": "Contribution"
}, {
"AlarmId": 3614481,
"ElementId": 312,
"ElementName": "MUN-X20-FRM-003_1_2_4_19",
"Severity": "Critical",
"ParameterDescription": "Signal Loss (Decoder Services) 3/Auto First Service [239.202.1.4:5000] 3G-1BD",
"ParameterValue": "BLACK_FRAME",
"StartTime": "/Date(1736262135000)/",
"ServiceInvolved": "",
"ClusterName": "Contribution"
}
] }
And you would get something like
Hi Apurva,
I’m not sure if this will help with your debugging, but the error "Sequence contains no element"
typically occurs when LINQ methods like .First()
, .Single()
, etc., are used on a collection that is either empty or null. These methods assume the collection contains at least one element and will throw this error if none are found.
To avoid this, it’s better to use .FirstOrDefault()
or .SingleOrDefault()
. These methods return null
when no elements are present, allowing you to handle such cases more gracefully. After retrieving the result, you can add a check to see if it’s null
or empty before proceeding with the logic.
Using this approach can help ensure your code is more robust and avoids unexpected exceptions when dealing with empty collections.
Hi,
In API on swagger I pass this type of JSON and still get Sequence contains no element cant figure out what issue
{ "components": [
{
"AlarmId": 3614501,
"ElementId": 290,
"ElementName": "Sky-News-TXCore",
"Severity": "Critical",
"ParameterDescription": "Memory Usage (Servers Info) sky-news-pi-ams",
"ParameterValue": "70.000000",
"StartTime": "/Date(1736263098000)/",
"ServiceInvolved": [
"TX Core"
],
"ClusterName": "Contribution"
},
{
"AlarmId": 3614481,
"ElementId": 312,
"ElementName": "MUN-X20-FRM-003_1_2_4_19",
"Severity": "Critical",
"ParameterDescription": "Signal Loss (Decoder Services) 3/Auto First Service [239.202.1.4:5000] 3G-1BD",
"ParameterValue": "BLACK_FRAME",
"StartTime": "/Date(1736262135000)/",
"ServiceInvolved": [
],
"ClusterName": "Contribution"
}
]
}