Mantis mc_issue_relationship_add

I’ve got Functions for managing Mantis ‘tickets’, updating, adding notes, adding attachments but I’m hitting a problem with adding in a relationship to other tickets.
I can read the ticket and get relationships:
<pr>
$mantis = New-WebServiceProxy -Uri http://tickets.empyreanbenefits.com/api/soap/mantisconnect.php?wsdl
$ticketdetails = $mantis.mc_issue_get($Username,$Password,$ticket)
$ticketdetails.relationships

But when I try and add a relationship:

    $mantis = New-WebServiceProxy -Uri http://tickets.empyreanbenefits.com/api/soap/mantisconnect.php?wsdl
    $Relationship = New-Object "Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1pi_soap_mantisconnect_php_wsdl.issuerelationshipadd"
    $Relationship.id = $Ticket 
    $Relationship.type.id = 3
    $Relationship.Target_id = $TargetID
    $mantis.mc_issue_relationship_add($Username,$Password,$ticket,$Relationship)

I get this error:

New-Object : Cannot find type [Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1pi_soap_mantisconnect_php_wsdl.issuerelationshipadd]: verify that the 
assembly containing this type is loaded.

This may not be a PS native issue, but something relative mantis wsdl or other environment issue.
Usually this sort of error has to do with not doing something like the below.

[System.Reflection.Assembly]::LoadFrom('c:\SomeLibraryOrReference.dll')

All that being said, and full disclosure, I don’ t use Mantis nor do any of my customers I support / consult with / for. so see the below:

https://www.mantisbt.org/forums/viewtopic.php?f=2&t=24461 https://mantisbt.org/forums/viewtopic.php?f=3&t=25896 https://www.administrator.de/forum/powershell-soap-wsdl-mantis-bug-tracker-272228.html

[quote quote=115086][/quote]

Yes, you’re right, hence the “New-Object
“Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1pi_soap_mantisconnect_php_wsdl.issuerelationshipadd””

btw the mantis link you put in, for 25896, that’s my post asking them the same question, the 24461 and the one from administrator.de has no relevance to the issue, except that it’s also Mantis.

Solution is:

    $mantis = New-WebServiceProxy -Uri http://tickets.empyreanbenefits.com/api/soap/mantisconnect.php?wsdl
    $Relationship = New-Object ($mantis.GetType().Namespace + ".RelationshipData")
    $Relationship.id = $Ticket 
    $Relationship.Target_id = $TargetID
    $type = New-Object ($mantis.GetType().Namespace + ".ObjectRef")
    $type.id = 2
    $Relationship.type = $type
    $mantis.mc_issue_relationship_add($Username,$Password,$ticket,$Relationship)