Home Analyst Portal

Article / Knowledge Base API Calls

John_LongJohn_Long Customer Advanced IT Monkey ✭✭✭

Hey folks,

Am working on a similar initiative to docs.microsoft.com where we'll use YAML embedded markdown to create the KBs and then use a pipeline to transform to HTML and push to KB based on the YAML metadata.

I'm having a hard time finding the right Cireson API call to create/edit new knowledge base articles. I can see the portal itself using KnowledgeBase/HTMLKnowledgeSave for it, but that's a "private" API method so not that comfortable using it long term.

Any tips/tricks or insights? :) Thanks!

Answers

  • John_LongJohn_Long Customer Advanced IT Monkey ✭✭✭

    PS:

    A list of required properties for the formJSON would be amazing. When you get an error on POST, it's crazy hard to know why.

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    edited August 2019

    @John_Long - I recently used/modified this script by my teammate @john_doyle to create new KB articles from an external source. Maybe you can adapt it to your needs?

  • John_LongJohn_Long Customer Advanced IT Monkey ✭✭✭

    Thanks @Justin_Workman . I'll take a look and try to see if I've any differences. I copied the payload from the API help docx file and used that as the base.

  • John_LongJohn_Long Customer Advanced IT Monkey ✭✭✭

    @Justin_Workman Yeah my payload looks OK. I'm just getting a 200 with an empty response back and this in the WebConsole.log


    2019-08-30 15:43:29,109, ERROR [ 33]: System.NullReferenceException: Object reference not set to an instance of an object.

      at Cireson.ServiceManager.Services.Implementations.KnowledgeBaseService.<AddOrUpdateHTMLKnowledgeAsync>d__47.MoveNext()


    Would you happen to have a list of what attributes are mandatory for that object type? Something is clearly missing on my side.



  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭

    @John_Long - this is the slimmest json I've been able to get away with:

    formJson = @{

      isDirty = $true

      current = @{

        IsNew = $true

        ArticleId = 0

        Title = "Title missing"

        LanguageLocaleID = @{

         Id = "10CE36CE-AA59-4F36-9CE9-2AB6DF031A51"

         Name = "English"

         HierarchyLevel = 0

         HierarchyPath = $null

        }

        KACategory = @{

         Id = $null

         Name = ""

         HierarchyLevel = 0

         HierarchyPath = $null

        }

        Type = $null

        KAType = @{

         Id = $null

         Name = ""

         HierarchyLevel = 0

         HierarchyPath = $null

        }

        NameRelationship = @(

         @{

          Name = "RelatesToIncident"

          Class = "943d298f-d79a-7a29-a335-8833e582d252"

          RelationshipId = "42179172-3d24-cfc8-3944-b0a18f550214"

         }

        )

        RelatesToIncident = @{

         DisplayName = $null

         BaseId = $null

         ObjectGuid = $null

        }

         RelatesToServiceOffering = @()

        RelatesToRequestOffering = @()

        CreatedBy = $createdByUserId

        CreatedDate = "0001-01-01T00:00:00.000Z"

        LastModifiedBy = $createdByUserId

        LastModifiedDate = "0001-01-01T00:00:00.000Z"

        Status = @{

         Id = "9508797e-0b7a-1d07-9fa3-587723f09908"

        }

       }

      original = $null

      }

    }

  • John_LongJohn_Long Customer Advanced IT Monkey ✭✭✭

    Thanks for the above. The PowerShell runs through no problem so it must be something in my Python that’s not quite right. Leaning towards encoding or something as the JSON looks OK.

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭

    You might try to wireshark it? Watch the request come from powershell and from python then compare them?

  • John_LongJohn_Long Customer Advanced IT Monkey ✭✭✭

    Been using Fiddler, rather than Wireshark, to inspect the JSON in transit. I couldn't spot the issue on Friday but maybe will have more luck today, even if Monday morning eyes aren't the best! :D

Sign In or Register to comment.