3

I am trying to create a new PublicationTarget with PowerShell, using the 2010 CoreService interface.

I have to following code within a function (separated for clarity):

(first block of code, seems to be correct)

$newTarget = $client.getdefaultdata([core.ItemType]::PublicationTarget, $true, $readOptions)
$newTarget.title = $type.title
$newTarget.description = $type.description
$newTarget.targetlanguage = "JSP"

(second block of code, unsure where to add what...)

$schema = new-object core.SchemaData    
$link = new-object core.LinkToSchemaData
$link.idref = $schema
$link.title = "my link schema title"

(third block of code, unsure what to do with it...)

$protocol = new-object System.Xml.XmlDocument
$protocol.loadxml("<Local xmlns=`"http://www.tridion.com/ContentManager/5.0/Protocol/LocalFileCopy`"><Location>c:\temp</Location></Local>")

(fourth block of code, seems correct to me)

$dest = new-object core.TargetDestinationData    
$dest.protocolschema = $link
$dest.protocoldata = $protocol

(last block, glueing everthing together)

$newTarget.destinations = $dest 
$result = $client.create($newTarget, $readOptions)

Code for the allowed publications and allowed target types is still missing.

There is something missing, I guess, in the SchemaData (second block), but what?

There is something wrong, in the $protocol definition, because of the error message:

"The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://www.sdltridion.com/ContentManager/CoreService/2010:data.
 The InnerException message was 'There was an error deserializing the object of type Tridion.ContentManager.Data.IdentifiableObjectData.
 Data at the root level is invalid.

I hope someone can point me into the right direction to fix the error message.

1 Answer 1

2

I think in your second block you are setting a schema in IdRef which I think should be a Tcmuri of the protocol schema.

$link = new-object core.LinkToSchemaData
$link.idref = "tcm:0-???-8"
$link.title = "my link schema title"

And in the last block it should be an array

1
  • Well, I have added those but the error is still the same: Exception calling "Create" with "2" argument(s): "The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter sdltridion.com/ContentManager/CoreService/2010:data.
    – user348
    Commented Sep 11, 2013 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.