Knowledge base API documentation

Hi,

Is there any documentation about the API for the knowledge base?

A “common” API calls like:
curl -H "Authorization: Token token=********" https:///api/v1/knowledge_bases/search?query=article.body:Test

returns:
{“error”:“Not authorized (token)!”}

The token was created including KNOWLEDGE_BASE: EDITOR and READER rights. The token works with tickets though.

Any help?

Matias

1 Like

Negative as of now.
If it helps as of now, you can take a look into your network tab of a develoepr console in the browser, it will tell you what it does.

This helps… :slight_smile:
Thanks! M.

@MrGeneration Please is it possible to make a POST or PATCH /api/v1/knowledge_bases? e.g. to add or to edit a answer.


Regards
Epi

In this case it’s a PATCH.
image

Not sure what really is needed, but your browsers developer console should provide all needed hints to help you in the right direction. This endpoint is currently not documented which is why I can’t help too good. :frowning:

1 Like

Thanks for your reply! Indeed the browser developer console was a huge help to achieve that stuff!
Do you have any hints, how to make or auto generate the table of contents?

1 Like

Glad that could help.
Easiest way to bring tables inside Zammad is to create the table (and preferebly it’s content) within e.g. Word, Outlook or theoretically any other document manipulation tool that works with HTML.

Just ensure to not make it a fancy table.
Color formating and formating of tables will proberbly fail.


If you’re searching for a table of contents in the knowledgebase, then I’m sorry - Zammad doesn’t have that at the moment. I was sure that there’s a feature request already, but failed to find one. So congratz, you’re the first. :smiley:

Creating a feature request on this community for voting and weighting reasons would be great. :slight_smile:

Can you give me example (simple curl call would help) how to edit a knowledge article by a curl call - or a link to a full documentation of the knowledge base api
Thank you very much in advance

Hi Martin,

Add an article:
POST api/v1/knowledge_bases/1/answers

{
  "category_id": "1",
  "translations_attributes": [
    {
      "title": "Some Title",
      "content_attributes": {
        "body": "Your content here"
      }
    }
  ]
}

Edit an article:

PATCH api/v1/knowledge_bases/1/answers

{
  "category_id": "1",
  "translations_attributes": [
    {
      "title": "Some edited Title",
      "id" : "100",
      "content_attributes": {
        "body": "Your edited content here"
      }
    }
  ]
}

Thank you very much for the fast answer. But doesnt work for me.
I’m getting 404 Not found Requested resource was not found
It’s the latest Zammad 3.3
I can list with …/api/v1/knowledge_bases/1/answers/1

Advancing a little bit, with a post to /api/v1/knowledge_bases/1
(without answers) im getting
{“error”:“Translations kb locale must exist”,“error_human”:“Translations kb locale must exist”}

Now passing the Accept-Languate:de-de, i get:
{“error”:“Category must exist”,“error_human”:“Category must exist”}
I have only 1 Category with id 1 (i think)

Sorry I forget to mention the parameter kb_local_id probably 1 is for the German.

Add an article:

POST /api/v1/knowledge_bases/1/answers
{
  "category_id": "1",
  "translations_attributes": [
    {
      "title": "Some Title",
      "kb_local_id" : "1",
      "content_attributes": {
        "body": "Your content here"
      }
    }
  ]
}

I guess you didn’t configure properly you knowledge base account. Or the category Id you are using ID different to the existing one. Just click on the category you created and you will see the cat-ID on your browser link. e.g : /#knowledge_base/1/locale/de-de/category/2 In that example 2 is my category ID

is see in the browser:
knowledge_base/1/locale/de-de/answer/1
so category_id is 1

i did not configure the knowledge base account at all :wink:
the user is admin and has all access

Nope that ID refers to the answer

knowledge_base/1/locale/de-de/category/1
so do category is 1
i dont know whats wrong

I have figured out at least the PATCH now:
curl -X PATCH -k -H ‘Content-Type: application/json’ -H ‘Authorization: Basic xxxxxxxxxxxxxxxx==’ -i ‘https://xxxxxxxxxxxxx/api/v1/knowledge_bases/1/answers/2’ --data ‘{
“category_id” : “1”,
“translations_attributes”: [
{
“title”:“Neueste Helfer Liste”,
“id”:2,
“content_attributes”: {
“body”: “Hier kommt die Liste xxxxxxxxxxxxxxx”
}
}
],
“full”: “true”,
“knowledge_base_id”:“2”,
“id”: “2”
}’

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.