๐ขContent
Get content
GET /wiki/rest/api/content
Returns all content in a Confluence instance. By default, the following objects are expanded: space, history, version.
package main
import (
"context"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
var (
contentID = "64290828"
expand = []string{"any"}
version = 1
)
content, response, err := instance.Content.Get(context.Background(), contentID, expand, version)
if err != nil {
if response != nil {
log.Println(response.Code)
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
log.Println(content)
}Create content
POST /wiki/rest/api/content
Creates a new piece of content or publishes an existing draft. To publish a draft, add the id and status properties to the body of the request.
Set the
idto the ID of the draft and set thestatusto 'current'.When the request is sent, a new piece of content will be created and the metadata from the draft will be transferred into it.
By default, the following objects are expanded:
space,history,version.
Get content by ID
GET /wiki/rest/api/content/{id}
Returns a single piece of content, like a page or a blog post. By default, the following objects are expanded: space, history, version.
Update content
PUT /wiki/rest/api/content/{id}
Updates a piece of content. Use this method to update the title or body of a piece of content, change the status, change the parent page, and more.
Delete content
DELETE /wiki/rest/api/content/{id}
Moves a piece of content to the space's trash or purges it from the trash, depending on the content's type and status:
If the content's type is
pageorblogpostand its status iscurrent, it will be trashed.If the content's type is
pageorblogpostand its status istrashed, the content will be purged from the trash and deleted permanently. Note, you must also set thestatusquery parameter totrashedin your request.If the content's type is
commentorattachment, it will be deleted permanently without being trashed.
Get content history
GET /wiki/rest/api/content/{id}/history
Returns the most recent update for a piece of content.
Search Contents by CQL
GET /wiki/rest/api/content/search
Returns the list of content that matches a Confluence Query Language (CQL) query. For information on CQL, see: Advanced searching using CQL.
Archive Pages
POST /wiki/rest/api/content/archive
Archives a list of pages. The pages to be archived are specified as a list of content IDs. This API accepts the archival request and returns a task ID.
Last updated
Was this helpful?
