How to call InvokeMethod with AddUserDefinedEvent using ManagementServer/ConfigurationApiService.svc

Hi,

I’m trying to use ManagementServer/ConfigurationApiService.svc to create the definition of a UserDefinedEvent (or AnalyticsEvent).

I read the documentation and If I understand correctly, first I have to call GetItem (with path ‘/UserDefinedEventFolder’) and pass the result to InvokeMethod specifying “AddUserDefinedEvent” as the method.

The call to GetItem is successful and I get.

{
  "GetItemResult": {
    "Children": null,
    "ChildrenFilled": false,
    "DisplayName": "User defined events",
    "ItemCategory": "Group",
    "ItemType": "UserDefinedEventFolder",
    "MethodIds": {
      "string": [
        "AddUserDefinedEvent",
        "RemoveUserDefinedEvent"
      ]
    },
    "ParentPath": "/",
    "Path": "/UserDefinedEventFolder",
    "SortKey": 100,
    "UIHint": "DirectionHorizontal"
  }
}

When I call InvokeMethod instead I get the following error.

“Invalid MethodId AddUserDefinedEvent on ItemType: UserDefinedEventFolder”.

I also tried calling InvokeMethod passing a UserDefinedEvent item, but I get a similar error “Invalid MethodId AddUserDefinedEvent on ItemType: UserDefinedEvent”.

Below is the node.js code that I use.

client.GetItem({path:'/UserDefinedEventFolder'}, function(err, result, rawResponse, soapHeader, rawRequest) {
	var item = result.GetItemResult;
	client.InvokeMethod({item:item, method: "AddUserDefinedEvent"} , function(err, result, rawResponse, soapHeader, rawRequest) {
		console.log(JSON.stringify(result, null, 2) );
	});
});

Why doesn’t it work? What am I doing wrong?

Thanks,

Best regards

Vincenzo

Hi. Please run Config API Client sample. Can you add a new user-defined event with the sample? If you can, please trace the sample code when you add a new user-defined event.

https://doc.developer.milestonesys.com/html/index.html?base=samples/configapiclient.html&tree=tree_2.html

Thanks for the reply. I tried with wireshark but the protocol is encrypted. How can I trace the request/ response? Best regards ​

The snippet you provided looks okay - I’m surprised you’d get that error when AddUserDefinedEvent is most definitely a MethodId on that ConfigurationItem.

I’d recommend trying out the sample linked to by @Rie Kiuchi (Milestone Systems)​ , and if you’re interested in an interactive test, you can use my MilestonePSTools module to work with ConfigurationAPI interactively via PowerShell. For me, this has really helped cement my understanding of the requests/responses and what to expect, since you can easily try different things and explore the properties from a native .NET interpreter.

Connect-ManagementServer
$udeFolder = Get-ConfigurationItem -Path /UserDefinedEventFolder
$udeFolder
 
$invokeInfo = $udeFolder | Invoke-Method AddUserDefinedEvent
$invokeInfo
 
$invokeInfo.Properties[0].Value = "Test UDE"
$invokeResult = $invokeInfo | Invoke-Method AddUserDefinedEvent
$invokeResult
 
 
ExtensionData  : System.Runtime.Serialization.ExtensionDataObject
Children       : {}
ChildrenFilled : False
DisplayName    : User defined events
EnableProperty : 
ItemCategory   : Group
ItemType       : UserDefinedEventFolder
MethodIds      : {AddUserDefinedEvent, RemoveUserDefinedEvent}
ParentPath     : /
Path           : /UserDefinedEventFolder
Properties     : 
ServerCookie   : 
SortKey        : 100
UIHint         : DirectionHorizontal
 
ExtensionData  : System.Runtime.Serialization.ExtensionDataObject
Children       : {}
ChildrenFilled : False
DisplayName    : Add user-defined event
EnableProperty : 
ItemCategory   : Item
ItemType       : InvokeInfo
MethodIds      : {AddUserDefinedEvent}
ParentPath     : /
Path           : /UserDefinedEventFolder
Properties     : {Name}
ServerCookie   : 
SortKey        : 100
UIHint         : DirectionVertical
 
ExtensionData  : System.Runtime.Serialization.ExtensionDataObject
Children       : {}
ChildrenFilled : False
DisplayName    : Result
EnableProperty : 
ItemCategory   : Item
ItemType       : InvokeResult
MethodIds      : {}
ParentPath     : /UserDefinedEventFolder
Path           : UserDefinedEvent[5A64431E-7379-449D-B25F-0A3C05D9AF0C]
Properties     : {Id, Name, LastModified, CreatedDate...}
ServerCookie   : 
SortKey        : 100
UIHint         : 

Thanks for the code. I Will try your tool. Is there a way to see soap request/response? ​

I’ve never tried following ConfigAPI traffic in Wireshark. I’m assuming it’s encrypted or obfuscated. If the sample from the SDK doesn’t work either, then I’d open a support ticket.

I tried your tool and it works. Apparently I’m doing the same thing, but it doesn’t work.

I tried with Wireshark but I can’t see the SOAP request/response of your tool (they are encrypted) and therefore I am not able to know where I am wrong.

What can I do?

Best regards