Node-related REST APIs

A node is the overarching type used to represent all containers in the AnswerHub Hierarchy. We designed this section to guide you in creating API requests that involve nodes.

Documentation Related to Nodes

📘

More Details on Nodes & a Note on nodeIds:

  • Nodes are the overarching base type used to describe more specific node sub-types (question, answer, comment, etc). The system defines the majority of operations and request URLs in a node, at the level of the specific sub-types. However, some operations apply to several, if not all, node sub-types.
    • All concrete sub-types of node (questions, answers, or comments) share the same pool of assigned identifiers. The nodeId is enough information for the server to process a request for any of these sub-nodes.

❗️

Removed APIs:

We have temporarily removed the publish node, send to moderation, reject node, and cancel rejection of node API requests, from this guide because we do not currently support them. However, they are still available if they are already being used.

Data Models

Node Data Models

The system uses the node data model as the basis from which it extends other container types. Many of the specific sub-node data types can reuse the main node data model.

This table summarizes the fields supported by the base node type in addition to all the specific types that extend or reuse node functions:

Field NameTypeExample(s)Description
nodeIdID: 64bit Integer134This ID serves as an identifier for the node to which a request is being made.
creationDateTimestamp1328817889000This date specifies the posting date of the specified node.
creationDateFormattedString2/9/12 15:04This is the node creation date, formatted based on the location from which the API request is made.
titleStringHow to use TeamHub REST APIThis is the title of the node.
bodyStringBody text can be anything.The body contains the textual content of the node.
bodyAsHTMLStringBody text can be anything.The bodyAsHTML contains the textual content of the node, written in HTML.
authorUser{id,username}{12, "james007"}The author is the user that posted the node originally.
Note: This parameter only has 2 sub-fields: id and username.
lastEditedActionIdID: 64bit Integer43This is the ID of the last edit or update action made to the node.
activeRevisionIdID: 64bit Integer43This is the ID of the last revision made to the node.
revisionIdsID[ ]: 64bit Integer43,44,56The revisionIds is the array of IDs connected to any revisions made to the node.
lastActiveUserId64bit Integer23This is the ID of the user that made the most recent edit or update to the node.
lastActiveDateTimestamp1328817889000This is the date of the most recent edit or update to the node.
parentIdID: 64bit Integer34This is the ID of the parent node (the node within which the current node nests).
originalParentIdID: 64bit Integer56This is the ID of the current node's root ancestor node (the highest node in the Hierarchy that the current was created within).
childrenIdsID: 64bit Integer45This is the ID of a child node (a node which nests within the current node).
commentIdsID[ ]: 64bit Integer32This is the array of IDs connected to comments made within the current node.
markedBooleantrueThis field can have a value of true or false. If true, the node (in almost all cases, a question) has an accepted answer. If false, there is no accepted answer to a question.
topicsString[IT,trends]This is the array of topic names (sometimes called labels or tags) associated with the current node.
primaryContainerIdID: 64bit Integer3324This is the ID associated with a specific TeamHub space. (A space is a sub-site container type.)
containerIdsID[ ]: Integer23This is the ID of the TeamHub spaces associated with an API node request.
V2: slugStringhow-to-post-a-commentThis is the slug representation of node title. (A slug is a listing of lower-case words chained together using hyphens -.)
wikiBooleantrueThis field can have a value of true or false. If true, the node exists as a wikified page. (Anyone with access can make changes to the node.)
scoreInteger254This is the number of received votes (likes, thumbs-ups) for the given node.
depthInteger1This number represents the number of steps between the originating ancestor node and the current node. (For example, if the requested node (c) nests within another node (b), that nests within the ancestor node (a), then the depth would be 2.)
acceptedBooleantrueThis field can have a value of "true" or "false." If true, the node (in almost all cases, a question) has an accepted answer.
attachmentsAttachment{filename: 'birds.png', size:1024 ,sizeFormatted: '1K', url: '...'}, ..This is an array of the attachments connected to the requested node.
totalCountinteger10This value tells you how much of specific node type exists.

Attachment Data Model

You may post a node with, or update it to have, a number of attachments (such as multimedia or documents) that complement the main content of the node. The system models details of each attachment retrieved embedded in a node, with the attachment type.

The table below summarizes the fields supported by abstract attachment type and all concrete types extending or reusing attachments.

Field NameTypeExample(s)Description
filenameStringmyproject-architecture.pngThis is the filename of an attachment.
sizeInteger641024This is the size of an attachment (in bytes).
sizeFormattedString1KB; 10.5KB; 1M; 1G; 1T; 1P; 1EThis is the human-readable (simplified) representation of the size of an attachment.
urlString (URL)http://teamhub.mycompany.com/storage/image/1234-birds.pngThis is the URL of an attachment.

NodeRequest Data Model

When making a request to post or edit sub-types of a node, use an object of NodeRequest type. The fields available for a NodeRequest are a sub-set of the fields available in the basic node type. The system removes some fields as they automatically generate and the TeamHub server manages them, both when the instance is first created or whenever actions are performed.

The table below summarizes the fields supported by an abstract NodeRequest type and all concrete types extending or reusing NodeRequest.

Field NameTypeExample(s)Description
attachmentsAttachmentRequest{filename:'birds.png', mimeType: 'image/png', content: '..'}, ..This is the array of attachments to add to a node.
authorIdID: 64bit Integer7This is the ID of the real user making the node POST request.
bodyStringI'm trying ...This is the main body of text the node request creates.
userIdID: 64bit Integer7This is the ID of the user that shows up as the author of the node.
usernameStringjack83This is the username (sometimes referred to as an alterego in TeamHub documentation) of the user that shows up as the author of the node.

AttachmentRequest Data Model

You may post or update a node to have a number of attachments (multimedia or documents), that complement the main content of the node. The system models the details of each attachment, as sent in a NodeRequest, after the AttachmentRequest type.

The fields available for an AttachmentRequest are a sub-set of the fields in the attachment type, as returned embedded in a node.

An example of this in use is available under Question-related REST APIs with the "Post a new question" API request.

The table below summarizes the fields supported by the abstract AttachmentRequest type and all concrete types extending or reusing the AttachmentRequest type.

Field NameTypeExample(s)Description
filenameStringmyproject-architecture.pngThis is the filename of an attachment.
mimeTypeString (Mime Type)image/png, image/gif, application/pdfThis field gives the MIME type for the attached content.
contentString(64base encoded byte[])asdh89ras8fah8hasdsaf98This is the base64 representation of the image.