[SalesForce] How to get knowledge article publish via REST

Reading https://resources.docs.salesforce.com/sfdc/pdf/salesforce_knowledge_dev_guide.pdf

It looks to me like it should be possible to publish a master article and settranslation of articleversion via the REST service but I am unable to find the URLs endpoint for this in the rest explorer (workbench) or any example on the web.

I am using https://github.com/developerforce/Force.com-Toolkit-for-NET and C#. I can't find any reference to knowledge in there as well but that should be easy to adjust when the service I need is available.

Any ideas how to get imported articles published via REST?


Hi Saroj,

Thanks for answering. Here is what I tried:

I added a function to the ForceClient.cs of the toolkit to expose the URL.

public Task<SuccessResponse> PublishArticleAsync(object record, string VersionId)
{
 if (record == null) throw new ArgumentNullException("record");
 if (string.IsNullOrEmpty(VersionId)) throw new ArgumentNullException("VersionId");

 return _serviceHttpClient.HttpPatchAsync(record, string.Format("/knowledgeManagement/articleVersions/masterVersions/{0}", VersionId));
 }

Create an ArticleVersion(KAV) via the API, this works fine, articleVersion (KAV) is created and on Draft. Since it’s new, the system seems to create an Article (KA) itself (I think?)

Salesforce.Common.Models.SuccessResponse CreateTask = await API.CreateArticle(DocType.APIArticleTypeVersion, Article);

To get the just created articleversion I perform a QueryAllAsync on the return id from the create task (returning the versionid: string q = "SELECT Id, KnowledgeArticleId, MasterVersionId FROM " + namespacePrefix + ArticleType_KA + " WHERE Id = '" + id + "'").

Salesforce.Common.Models.QueryResult<dynamic> FindTask = await API.FindArticleVersion(DocType.APIArticleTypeVersion, CreateTask.Id);

So far, so good. Created article is found and the MasterVersionId from it is retrieved. Next I want to publish it. So I pass the masterversionid which is present on the result)

Salesforce.Common.Models.SuccessResponse PublishTask = await API.PublishArticle(FindTask.Records[0]["MasterVersionId"]);

Which is implemented by

public async Task<SuccessResponse> PublishArticle(string VersionId)
{
dynamic Publish = new ExpandoObject();
Publish.publishStatus = "Online";
SuccessResponse Result = await client.PublishArticleAsync(Publish, VersionId);
return (Result);
}

Whatever id (articleid, masterversionid, id of the articleversion), I seem to pass, the result is always “The requested resource does not exists.”

I am obviously missing something here but just can’t find it…Any ideas?

Best Answer

To Publish the Master Version of an Article follow the endpoint and Salesforce documentation as below.

Endpoint: /services/data/v25.0/knowledgeManagement/articleVersions/masterVersions/<versionId>

https://developer.salesforce.com/docs/atlas.en-us.knowledge_dev.meta/knowledge_dev/knowledge_REST_publish_master_version.htm

Related Topic