3

Hi I am trying to publish content using core service, I am getting following error

Value cannot be null.\r\nParameter name: source

here is following code I am using to publish

_client.Publish(new String[] { id }, pid, purposes.toArray(), PublishPriority.Low, new ReadOptions());

not able to understand parameter name: source could someone please suggest me.

2
  • I can see your 2nd parameter something pid what was that? that should be publishInstruction object. eg. var publishInstruction = new PublishInstructionData { ResolveInstruction = new ResolveInstructionData()}; – Velmurugan Apr 12 at 21:17
  • Hi @Velu, thanks for response, pid is PublishInstructionData object only. – Neetesh Narvaria Apr 13 at 14:38
3

The error happens if you call a Linq statement on a null object. The only Linq statement in your code is ToArray(). My guess is that the variable purposes is null.

2
  • Hi @Quirijn, thanks for response, but I have added null check on the code and tried to debug code, purposes.ToArray(), it is throwing error even it has values. – Neetesh Narvaria Apr 13 at 14:37
  • 1
    After lot debugging just found when we pass target id, it works, but when we pass purpose array it just throws error: Value cannot be null – Neetesh Narvaria Apr 13 at 14:59
2

After lot debugging was able to figure out that on below code

_client.Publish(new String[] { id }, pid, purposes.toArray(), PublishPriority.Low, new ReadOptions());

I was passing string array on purposes i.e. Live, Live1

But Publish method on core-service is expecting id instead of purpose string.

Previously I was fetching purpose string by below line of code

bpt.TargetTypes.Select(targetTypes => targetTypes.Purpose);

but when changed it to

bpt.TargetTypes.Select(targetTypes=> targetTypes.Id);

then Publish method doesn't fail and also push the item to Publish Queue.

1
  • Nice that you found a work-around, but it should work with Target purposes too. Can you provide a full Stack Trace (obtained from Tridion Event Log). That will provide more information of how/where it fails when you provide Target purposes. – Rick Pannekoek Apr 29 at 15:36
0

Publish Page coreservice example:

// Publish the page
var publishInstruction = new PublishInstructionData
{
     ResolveInstruction = new ResolveInstructionData()
};
PublishTransactionData[] unpublishTransactions = core.Publish(new[] { pageUri }, publishInstruction, destinationTargetUrisOrPurposes, PublishPriority.Normal,new ReadOptions());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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