Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Publish KnowledgeArticle via the Web API

Posted on by Microsoft Employee

Hi,

What is the process to publish a KnowledgeArticle via the Web API? I have been able to successfully post a KnowledgeArticle in draft state, but need to move it to Published state. Here is my code to publish in draft state in C#

JObject jObject = new JObject();

            jObject["content"] = kba.Content;
            jObject["title"] = kba.Title;
            jObject["createdon"] = DateTime.Now;
            jObject["modifiedon"] = DateTime.Now;
            jObject["knowledgearticleviews_date"] = DateTime.Now;
            jObject["rating_date"] = DateTime.Now;
            jObject["knowledgearticleid"] = Guid.NewGuid().ToString();
            jObject["description"] = kba.Description;

            var client = new RestClient(Settings.DynamicsApiUrl + "/knowledgearticles");
            var request = new RestRequest(Method.POST);
            request.AddParameter("authorization", string.Format("Bearer " + _authToken), ParameterType.HttpHeader);
            request.AddParameter("application/json", jObject.ToString(), ParameterType.RequestBody);
            request.RequestFormat = DataFormat.Json;
            request.AddBody(jObject.ToString());

            IRestResponse response = client.Execute(request);

            if (!response.IsSuccessful)
                throw new Exception(response.Content);


*This post is locked for comments

  • Suggested answer
    ThomasN Profile Picture
    ThomasN 3,190 on at
    RE: Publish KnowledgeArticle via the Web API

    Hi Hpop, thanks for reaching out.

    Not sure what you have already tried, but this should be simple as adding the attributes statecode, and statuscode both equal to publish. Here is link to API, but verify your metadata matches. docs.microsoft.com/.../knowledgearticle

    Also there is a field publishstatusid which might be required. Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans