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 Name

Type

Example(s)

Description

nodeId

ID: 64bit Integer

134

This ID serves as an identifier for the node to which a request is being made.

creationDate

Timestamp

1328817889000

This date specifies the posting date of the specified node.

creationDateFormatted

String

2/9/12 15:04

This is the node creation date, formatted based on the location from which the API request is made.

title

String

How to use TeamHub REST API

This is the title of the node.

body

String

Body text can be anything.

The body contains the textual content of the node.

bodyAsHTML

String

Body text can be anything.

The bodyAsHTML contains the textual content of the node, written in HTML.

author

User{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.

lastEditedActionId

ID: 64bit Integer

43

This is the ID of the last edit or update action made to the node.

activeRevisionId

ID: 64bit Integer

43

This is the ID of the last revision made to the node.

revisionIds

ID[ ]: 64bit Integer

43,44,56

The revisionIds is the array of IDs connected to any revisions made to the node.

lastActiveUserId

64bit Integer

23

This is the ID of the user that made the most recent edit or update to the node.

lastActiveDate

Timestamp

1328817889000

This is the date of the most recent edit or update to the node.

parentId

ID: 64bit Integer

34

This is the ID of the parent node (the node within which the current node nests).

originalParentId

ID: 64bit Integer

56

This is the ID of the current node's root ancestor node (the highest node in the Hierarchy that the current was created within).

childrenIds

ID: 64bit Integer

45

This is the ID of a child node (a node which nests within the current node).

commentIds

ID[ ]: 64bit Integer

32

This is the array of IDs connected to comments made within the current node.

marked

Boolean

true

This 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.

topics

String

[IT,trends]

This is the array of topic names (sometimes called labels or tags) associated with the current node.

primaryContainerId

ID: 64bit Integer

3324

This is the ID associated with a specific TeamHub space. (A space is a sub-site container type.)

containerIds

ID[ ]: Integer

23

This is the ID of the TeamHub spaces associated with an API node request.

V2: slug

String

how-to-post-a-comment

This is the slug representation of node title. (A slug is a listing of lower-case words chained together using hyphens -.)

wiki

Boolean

true

This 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.)

score

Integer

254

This is the number of received votes (likes, thumbs-ups) for the given node.

depth

Integer

1

This 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.)

accepted

Boolean

true

This field can have a value of "true" or "false." If true, the node (in almost all cases, a question) has an accepted answer.

attachments

Attachment

{filename: 'birds.png', size:1024 ,sizeFormatted: '1K', url: '...'}, ..

This is an array of the attachments connected to the requested node.

totalCount

integer

10

This 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 Name

Type

Example(s)

Description

filename

String

myproject-architecture.png

This is the filename of an attachment.

size

Integer64

1024

This is the size of an attachment (in bytes).

sizeFormatted

String

1KB; 10.5KB; 1M; 1G; 1T; 1P; 1E

This is the human-readable (simplified) representation of the size of an attachment.

url

String (URL)

http://teamhub.mycompany.com/storage/image/1234-birds.png

This 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 Name

Type

Example(s)

Description

attachments

AttachmentRequest

{filename:'birds.png', mimeType: 'image/png', content: '..'}, ..

This is the array of attachments to add to a node.

authorId

ID: 64bit Integer

7

This is the ID of the real user making the node POST request.

body

String

I'm trying ...

This is the main body of text the node request creates.

userId

ID: 64bit Integer

7

This is the ID of the user that shows up as the author of the node.

username

String

jack83

This 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 Name

Type

Example(s)

Description

filename

String

myproject-architecture.png

This is the filename of an attachment.

mimeType

String (Mime Type)

image/png, image/gif, application/pdf

This field gives the MIME type for the attached content.

content

String(64base encoded byte[])

asdh89ras8fah8hasdsaf98

This is the base64 representation of the image.