Dan Martinez
Tera Expert

Overview

Have you ever wondered what is the best way to export articles from ServiceNow? One might think that is an easy task. At the end of the day, all you have to do is exporting the kb_article record itself and off we go, right? But wait, because knowledge blocks are calculated when the article is displayed, therefore are not stored within the article itself. But how about retrieving their attachments? how about retrieving the most viewed articles?

In order to solve these kinds of issues, ServiceNow offers the Knowledge API plugin (sn_km_api) which has been around for years, but turns out not many people know it exists after all.

 

Preparations

First of all, we need to install the Knowledge API (sn_km_api) plugin to enable this nice API to be consumed by external systems.

 

DanielGarciaM_0-1746006220960.png

 

Then we will need to create an account for that external system to be able to read our articles. The account will only need the rights for the articles that are required to be read. If the knowledge base you want to query requires you to belong to a group or have certain role, that is all you need.

 

Using the API

As any other API you can go to the REST API explorer to check it out, but bear in mind this API can be found under the “sn_km_api” namespace.

 

DanielGarciaM_1-1746006220970.png

 

On the left-hand side menu you can see the web services you can consume. Among these, you have “Get Article (GET)” which will allow you to retrieve not only the text of the article but also the embedded attachments and regular attachments sys_ids. Bear in mind that you will have to perform different calls to retrieve them.

 

This call, apart from grouping all knowledge blocks, will also calculate the visibility the user calling the API has. Let’s say our user has “itil” rights because we only want to share fulfiller articles to the external system. In such case, if a knowledge blocks was for any other role, such as “itil_admin”, that block wouldn’t be retrieved.

 

This is a great way not to leak information the external system is not supposed to be aware of, so don’t just give this account “admin” rights or you will export blocks dedicated to admins too!

 

DanielGarciaM_2-1746006220989.png

 

 

Additionally, and as it was mentioned before, you can also perform searches on articles, get the most viewed articles or featured articles among other actions.

 

If this blog article was useful to you, please click on “Helpful” and share it! 👍