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
  • Updates & Insights
  • Questions
  • Learning
    • E-learning Courses
    • Empower Replay: Limited Edition
    • Tutorials
    • 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
    • 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
    • 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
      • About the DevOps Program
      • DataMiner DevOps Support
  • Downloads
  • More
    • DataMiner Releases & Updates
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

Creating Microsoft Platform 6.0.0.2 elements via JSON API

Solved1.43K views15th February 2023Ansible API JSON API
13
Chris Glover [DevOps Advocate]1.15K 15th February 2023 1 Comment

Hi,

I’m using Ansible to create elements via the JSON API. I’m having a problem creating a Microsoft Platform element using protocol version 6.0.0.2

If I create the element in Cube, then grab the element config via API, I get

ok: [localhost] => {
“elementConfig.content”: {
“d”: {
“AlarmTemplate”: “”,
“CreateDVEs”: true,
“Description”: “”,
“EnableSnmpAgent”: false,
“EnableTelnet”: false,
“ForceAgent”: null,
“IPAddress”: “”,
“IPAddressMask”: “”,
“IsHidden”: false,
“IsReadOnly”: false,
“IsReplicationActive”: false,
“KeepOnline”: false,
“Name”: “Test Win 1”,
“Ports”: [
{
“DeviceAddress”: “”,
“ElementTimeoutTime”: 30000,
“GetCommunity”: “public”,
“IPAddress”: “192.168.192.246”,
“Network”: “0”,
“PortNumber”: 0,
“Retries”: 3,
“SNMPVersion”: 1,
“SetCommunity”: “private”,
“TimeoutTime”: 60,
“__type”: “Skyline.DataMiner.Web.Common.v1.DMAElementSNMPPortInfo”
},
{
“Baudrate”: 0,
“BusAddress”: “”,
“Databits”: 0,
“ElementTimeoutTime”: 30000,
“FlowControl”: “No”,
“IPAddress”: “192.168.192.246”,
“IPPort”: 0,
“LocalIPPort”: 0,
“Network”: “0”,
“Parity”: “No”,
“Retries”: 0,
“SerialPort”: “0”,
“Stopbits”: 0,
“TimeoutTime”: 60000,
“Type”: “TCP”,
“__type”: “Skyline.DataMiner.Web.Common.v1.DMAElementSerialPortInfo”
}
],
“ProtocolName”: “Microsoft Platform”,
“ProtocolVersion”: “6.0.0.2”,
“ReplicationInfo”: null,
“SlowPoll”: null,
“SnmpReadCommunityString”: “”,
“SnmpWriteCommunityString”: “”,
“State”: “Active”,
“TimeoutTime”: 30000,
“TrendTemplate”: “”,
“Type”: “Information Platform”,
“__type”: “Skyline.DataMiner.Web.Common.v1.DMAElementConfiguration”
}
}
}

I get an error around the ports config when I try to create the new elements.

The error I get is

fatal: [localhost]: FAILED! => {
“cache_control”: “private”,
“changed”: false,
“connection”: “close”,
“content”: “{\”Message\”:\”Invalid port configuration: expected Serial but received SNMP-Serial.\”,\”StackTrace\”:\”\”,\”ExceptionType\”:\”Skyline.DataMiner.Web.Common.WebApiException\”}”,
“content_length”: “162”,
“content_type”: “application/json; charset=utf-8”,
“date”: “Wed, 15 Feb 2023 13:37:37 GMT”,
“elapsed”: 0,
“json”: {
“ExceptionType”: “Skyline.DataMiner.Web.Common.WebApiException”,
“Message”: “Invalid port configuration: expected Serial but received SNMP-Serial.”,
“StackTrace”: “”
},
“jsonerror”: “true”,
“msg”: “Status code was 500 and not [200]: HTTP Error 500: Internal Server Error”,
“redirected”: false,
“server”: “Microsoft-IIS”,
“sl_filter”: “ALLOWED (single request, by path), time=2023-2-15 13:37:37”,
“status”: 500,
“url”: “http://dm.redlab01.tv/API/v1/json.asmx/CreateElement”
}

My Ansible code is this:

– name: CreateElement
uri:
url: “{{jsonServer }}{{createElement}}”
return_content: yes
use_proxy: false
body_format: json
method: POST
body: ‘{
“connection”: “{{connection.json.d}}”,
“dmaID”: “{{item.dmaID}}”,
“viewIDs”: [-1],
“configuration”:
{
“Name”: “{{item.Name}}”,
“ProtocolName”: “{{item.Protocol}}”,
“ProtocolVersion”: “{{item.Protver}}”,
“Ports”: [
{
“DeviceAddress”: “”,
“ElementTimeoutTime”: 30000,
“GetCommunity”: “public”,
“IPAddress”: “{{item.SNMP_IP}}”,
“Network”: “0”,
“PortNumber”: 0,
“Retries”: 3,
“SNMPVersion”: 1,
“SetCommunity”: “private”,
“TimeoutTime”: 60,
“__type”: “Skyline.DataMiner.Web.Common.v1.DMAElementSNMPPortInfo”
},
{
“Baudrate”: 0,
“BusAddress”: “”,
“Databits”: 0,
“ElementTimeoutTime”: 30000,
“FlowControl”: “No”,
“IPAddress”: “{{item.IP}}”,
“IPPort”: 0,
“LocalIPPort”: 0,
“Network”: “0”,
“Parity”: “No”,
“Retries”: 0,
“SerialPort”: “0”,
“Stopbits”: 0,
“TimeoutTime”: 60000,
“Type”: “TCP”,
“__type”: “Skyline.DataMiner.Web.Common.v1.DMAElementSerialPortInfo”
}

]
}
}’

register: createdElementInfo

So, by using the same format as the API spits out, I get the error. I have successfully created elements which feature IP and SNMP (R&S Prismon) with Ansible.

I can’t see where this is going wrong. Any ideas greatly appreciated

Thanks

Chris Glover [DevOps Advocate] Selected answer as best 15th February 2023
Chris Glover [DevOps Advocate] commented 15th February 2023

NOTE: The question engine lost all the formatting from the above!

2 Answers

  • Active
  • Voted
  • Newest
  • Oldest
7
Chris Glover [DevOps Advocate]1.15K Posted 15th February 2023 3 Comments

I’ve managed to get it to work, more by luck than judgement. The following works

– name: CreateElement
uri:
url: “{{jsonServer }}{{createElement}}”
return_content: yes
use_proxy: false
body_format: json
method: POST
body: ‘{
“connection”: “{{connection.json.d}}”,
“dmaID”: “{{item.dmaID}}”,
“viewIDs”: [{{item.viewID}}],
“configuration”:
{
“Name”: “{{item.Name}}”,
“ProtocolName”: “{{item.Protocol}}”,
“ProtocolVersion”: “{{item.Protver}}”,
“AlarmTemplate”: “{{item.alarmTemplate}}”,
“TrendTemplate”: “{{item.trendTemplate}}”,
“Ports”: [
{
“DeviceAddress”: “”,
“ElementTimeoutTime”: 30000,
“GetCommunity”: “public”,
“IPAddress”: “{{item.SNMP_IP}}”,
“Network”: “0”,
“PortNumber”: 0,
“Retries”: 3,
“SNMPVersion”: 1,
“SetCommunity”: “private”,
“TimeoutTime”: 60,
“__type”: “Skyline.DataMiner.Web.Common.v1.DMAElementSNMPPortInfo”
},
{
“Baudrate”: 0,
“BusAddress”: “”,
“Databits”: 0,
“ElementTimeoutTime”: 30000,
“FlowControl”: “No”,
“IPAddress”: “{{item.IP}}”,
“IPPort”: 0,
“LocalIPPort”: 0,
“Network”: “0”,
“Parity”: “No”,
“Retries”: 0,
“SerialPort”: “0”,
“Stopbits”: 0,
“TimeoutTime”: 60000,
“Type”: “TCP”,
“__type”: “Skyline.DataMiner.Web.Common.v1.DMAElementSerialPortInfo”
}

]
}
}’

register: createdElementInfo

I wish I could post code snippets that keep the formatting.

Chris Glover [DevOps Advocate] Posted new comment 16th February 2023
Alex Silva commented 15th February 2023

Regarding code formatting, please vote on the feature suggestion below, spread the word, and lets make Skyline aware that pretty formatted code in questions is an important asset for the community.

https://community.dataminer.services/new-feature-suggestions/support-for-formatted-source-code-in-questions-and-answers-here-at-community/

Wim Bruynooghe [SLC] [DevOps Advocate] commented 16th February 2023

Thanks for sharing the solution! What exactly fixed it? Including the “AlarmTemplate” and “TrendTemplate” properties?

Chris Glover [DevOps Advocate] commented 16th February 2023

Hi Wim, unfortunately I have no idea what fixed it!
I got annoyed, left it for a bit, came back to it later and it worked!

10
Wim Bruynooghe [SLC] [DevOps Advocate]6.59K Posted 15th February 2023 0 Comments

We have also seen this issue before, but we didn’t investigate the root cause of this yet. It works when sending the JSON directly via Postman to the JSON API of DataMiner, but for some reason it doesn’t work in Ansible.

As a workaround it works when using the SOAP API in Ansible. There’s an example of this on docs.dataminer.services.

Wim Bruynooghe [SLC] [DevOps Advocate] Answered question 15th February 2023
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
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