powershellmantis

Mantis 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: $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.Target_id = $TargetID
$Relationship.relationship.id = 3
$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.

Solution

  • Look at the method definition:

    $mantis.mc_issue_relationship_add
    
    # OUTPUT:   
    #
    # OverloadDefinitions
    # -------------------
    # string mc_issue_relationship_add(string username, string password, string issue_id, Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1pi_soap_mantisconnect_php_wsdl.RelationshipData relationship)
    

    You can see that the correct type is RelationshipData

    $Relationship = New-Object ($mantis.GetType().Namespace + ".RelationshipData")