1

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.
marsze
  • 15,079
  • 5
  • 45
  • 61
Iain
  • 123
  • 1
  • 6

3 Answers3

1

Big Thanks to Marsze for response above.

Final script is:

$uri = "http://tickets.empyreanbenefits.com/api/soap/mantisconnect.php?wsdl"
$mantis = New-WebServiceProxy -Uri $uri
$namespace = $mantis.GetType().Namespace
$relationship = New-Object "$namespace.RelationshipData"
$relationship.id = $Ticket 
$relationship.target_id = $targetId
$type = New-Object "$namespace.ObjectRef"
$type.id = 2
$relationship.type = $type
$mantis.mc_issue_relationship_add($username, $password, $ticket, $relationship)
marsze
  • 15,079
  • 5
  • 45
  • 61
Iain
  • 123
  • 1
  • 6
0

Try this way:

$mantis = New-WebServiceProxy -Uri http://tickets.empyreanbenefits.com/api/soap/mantisconnect.php?wsdl
$ProxyType = $mantis.GetType().Namespace
$Relationship = New-Object("$ProxyType.issuerelationshipadd")
$Relationship.issue_id = $Ticket 
$Relationship.Target_id = $TargetID
$Relationship.relationship.id = 3
$mantis.mc_issue_relationship_add($Username,$Password,$ticket,$Relationship)
Kirill Pashkov
  • 3,118
  • 1
  • 15
  • 20
0

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")
marsze
  • 15,079
  • 5
  • 45
  • 61