Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Blog
  • Questions
  • Learning
    • E-learning Courses
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • Tutorials
    • Video Library
    • Books We Like
    • >> Go to DataMiner Docs
  • Expert Center
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Markets & Industries
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • DataMiner Insights
      • Security
      • Integration Studio
      • System Architecture
      • DataMiner Releases & Updates
      • DataMiner Apps
    • Agile
      • Agile Webspace
      • Everything Agile
        • The Agile Manifesto
        • Best Practices
        • Retro Recipes
      • Methodologies
        • The Scrum Framework
        • Kanban
        • Extreme Programming
      • Roles
        • The Product Owner
        • The Agile Coach
        • The Quality & UX Coach (QX)
    • DataMiner DevOps Professional Program
  • Downloads
  • More
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
      • General Inquiries
      • DataMiner DevOps Support
      • Commercial Requests
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

Data interpreted and and measurement type using table editor

Solved319 views30th September 2024api parsing datatypes QAction table table editior
0
Chirangee lal Verma [DevOps Advocate]555 27th September 2024 0 Comments

{
"Instances": [
{
"Name": "DataMiner Main",
"IPAddress": "70.10.10.1",
"Id": 74947982479,
"CreatedFromTemplate": false,
"Status": "ACTIVE"
},
{
"Name": "DataMiner Backup",
"IPAddress": "10.10.10.2",
"Id": 76428745692,
"CreatedFromTemplate": true,
"Status": "STANDBY"
}
] }

this is the data i want to get in table and that's what i am getting

mentioning the csharp  code as well
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Newtonsoft.Json;
using Skyline.DataMiner.Scripting;

public static class Parameter
{
    public static class Instances
    {
        public const int tablePid = 300; // Replace with the correct table PID
    }
}

/// <summary>
/// DataMiner QAction Class: parse data.
/// </summary>
public static class QAction
{
    /// <summary>
    /// The QAction entry point.
    /// </summary>
    /// <param name="protocol">Link with SLProtocol process.</param>
    public static void Run(SLProtocol protocol)
    {
        try
        {
            // Get Text based json data as a string.
            string source = Convert.ToString(protocol.GetParameter(200));

            // Deserialize Json contents
            Rootobject rootObjects = JsonConvert.DeserializeObject<Rootobject>(source);
            List<object[]> instances = new List<object[]>();

            // Convert Generated class into Connector Row data.
            foreach (Instance instance in rootObjects.Instances)
            {
                instances.Add(new InstancesQActionRow
                {
                    Instancesid_301 = instance.Id,
                    Instancesname_302 = instance.Name,
                    Instancesipaddress_303 = instance.IPAddress,
                    Instancescreatedfromtemplate_304 = instance.CreatedFromTemplate,
                    InstancesStatus_305 = instance.Status,
                }.ToObjectArray());
            }

            protocol.FillArray(Parameter.Instances.tablePid, instances, NotifyProtocol.SaveOption.Full);
        }
        catch (Exception ex)
        {
            protocol.Log("QA" + protocol.QActionID + "|" + protocol.GetTriggerParameter() + "|Run|Deserializing JSON text failed due to:" + Environment.NewLine + ex, LogType.Error, LogLevel.NoLogging);
        }
    }
}

public class Rootobject
{
    public Instance[] Instances { get; set; }
}

public class Instance
{
    public string Name { get; set; }

    public string IPAddress { get; set; }

    public long Id { get; set; }

    public bool CreatedFromTemplate { get; set; }

    public string Status { get; set; }
}

public class InstancesQActionRow
{
    public long Instancesid_301 { get; set; }

    public string Instancesname_302 { get; set; }

    public string Instancesipaddress_303 { get; set; }

    public bool Instancescreatedfromtemplate_304 { get; set; }

    public string InstancesStatus_305 { get; set; }

    // Convert the properties to an object array for table insertion
    public object[] ToObjectArray()
    {
        return new object[]         {
            Instancesid_301,
            Instancesname_302,
            Instancesipaddress_303,
            Instancescreatedfromtemplate_304,
            InstancesStatus_305,
        };
    }
}

so what mistakes i m doing and how to fix that and appreciable if get content for improvement this process.

Chirangee lal Verma [DevOps Advocate] Selected answer as best 30th September 2024

1 Answer

  • Active
  • Voted
  • Newest
  • Oldest
3
João Severino [SLC] [DevOps Catalyst]12.94K Posted 27th September 2024 1 Comment

Hi Chirangee,

Could you share your parameter definition with us in the protocol.xml file?

I would guess you have them all defined as double/numeric types while for some of your data, you would need to define them as type string.

Chirangee lal Verma [DevOps Advocate] Selected answer as best 30th September 2024
João Severino [SLC] [DevOps Catalyst] commented 27th September 2024

As I suspected you have some definitions incompatible with your data.
You can reference this docs page for help https://docs.dataminer.services/develop/schemadoc/Protocol/Protocol.Params.Param.Measurement.html

But for your specific use case:
Instanceid
You should change your interprete to be RawType other and Type string
Then in the QAction you should define the primary key as a string as well

In your parameters Instancesname, Instancesname and data table nameStatus
RawType other
Type string

For the status and Instancescreatedfromtemplate you could consider using type discreet (see more https://docs.dataminer.services/develop/schemadoc/Protocol/Protocol.Params.Param.Measurement.Discreets.html)

Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas

Recent questions

Alarm Dashboard PDF/CSV Export 0 Answers | 0 Votes
Is the Microsoft SharePoint Connector Still Usable 0 Answers | 0 Votes
Is the Microsoft SharePoint Connector Still Usable 0 Answers | 0 Votes

Question Tags

adl2099 (115) alarm (62) Alarm Console (82) alarms (100) alarm template (83) Automation (223) automation scipt (111) Automation script (167) backup (71) Cassandra (180) Connector (108) Correlation (68) Cube (150) Dashboard (194) Dashboards (188) database (83) DataMiner Cube (57) DIS (81) DMS (71) DOM (139) driver (65) DVE (55) Elastic (83) Elasticsearch (115) elements (80) Failover (104) GQI (159) HTTP (76) IDP (74) LCA (151) low code app (166) low code apps (93) lowcodeapps (75) MySQL (53) protocol (203) QAction (83) security (88) services (51) SNMP (86) SRM (337) table (54) trending (87) upgrade (62) Visio (539) Visual Overview (345)
Privacy Policy • Terms & Conditions • Contact

© 2025 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs

[ Placeholder content for popup link ] WordPress Download Manager - Best Download Management Plugin