Uploading HTML KB articles using REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2018 10:08 AM
Hi,
We have a requirement to upload all externally hosted knowledge base HTML files to service now. HTML files contains few references to images and links to PDF. I have couple of questions,
a. Using REST API(Table API), I was able to add new record into kb_Knowledge table, how do I move this knowledge base article to published state in workflow?
b. Using REST API(Table API), I was able to add new image into db_images table, but the added image record does not have any image attached to it. How do I attach the image to a record in db_images table or update the image file for record in db_images table.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2018 10:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2018 03:30 PM
Hi, I found this article while looking for adding articles via API myself. I'm curious if you ever had luck with the db_images table via API... from what I've found, I think you want to use the REST API (Attachment API) to upload images instead of db_image... the files will wind up in the sys_attachment table, not db_image, but you can reference them like
<img src="/sys_attachment.do?sys_id={sysid_of_attachmentrecord}"/>
More info about Attachment API here: https://developer.servicenow.com/app.do#!/rest_api_doc?v=kingston&id=r_AttachmentAPI-POST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2018 04:20 AM
Hi Matt,
Yes, I was able to make it work.
a. First will be a post request to db_image table using TABLE API to create the image record in db_image table. Capture the sys_id from this request. This post request will contain actual image file name that you would use in src attribute of <img> tag.
b. Second request will be a post request with file contents to Attachment API with appropriate parameters in the query string,
{ServiceNow}/attachment/file?table_name=db_image&table_sys_id={imageSysId}&file_name=image"
table_sys_id will have the sys_id of the record in db_image table.
file_name - This parameter is not the actual file name. It should always remain as "image", this indicates that attachment should be tied to image field for the record in db_image table.