I want to publish my pages from the publication so I want to attach this publication into existing publication target. Here is my current code:

PublicationTargetData pd=(PublicationTargetData)client.read("tcm:0-7-65537",new ReadOptions());     
ArrayOfLinkToPublicationData linkpub=new ArrayOfLinkToPublicationData();        
LinkToPublicationData plinkData=new LinkToPublicationData();        
List l=linkpub.getLinkToPublicationData();  
client.update(pd,new ReadOptions()); 

This code is successfully attaching the Publication into the Publication Target but it unfortunately it replaces the Publication Target with the new one. But I don't want to remove the previous Publication from the Publication Target. So kindly suggest any solution.

2 Answers 2


You are instantiating a new ArrayOfLinkToPublicationData();, but instead you should take one which is already available on your publication target pd, add desired element and assign it back.


Try the below method to achieve the desired result

List<string> validPublications = new List<string>();
            ///Gets the list of Publications exisitng for current Publishing Target
            PublicationTargetData target = (PublicationTargetData)client.Read(PublishingTargetUri, new ReadOptions());
            foreach (LinkToPublicationData pub in target.Publications)

But this is not working in Web 8.5 when you pass a TargetType instead of PublicationTargetType(this returns null always in Web 8.5). Anyone has a solution for this scenario?

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.