Page cover

๐Ÿ—ƒ๏ธCustom Content

Get custom content by type

Returns all custom content for a given type.

package main

import (
	"context"
	"fmt"
	confluence "github.com/ctreminiom/go-atlassian/confluence/v2"
	"github.com/ctreminiom/go-atlassian/pkg/infra/models"
	"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")

	options := &models.CustomContentOptionsScheme{
		IDs:        nil,
		SpaceIDs:   nil,
		Sort:       "",
		BodyFormat: "",
	}

	customContents, response, err := instance.CustomContent.Gets(context.Background(), "pages", options, "", 10)
	if err != nil {

		if response != nil {
			log.Println(response.Bytes.String())
		}

		log.Fatal(err)
	}

	for _, customContent := range customContents.Results {
		fmt.Println(customContent.ID)
		fmt.Println(customContent.CustomContentID)
		fmt.Println(customContent.Status)
		fmt.Println(customContent.Title)
		fmt.Println(customContent.ID)
	}
}

Create custom content

POST /wiki/api/v2/custom-content

Creates a new custom content in the given space, page, blogpost or other custom content.

Get custom content by ID

GET /wiki/api/v2/custom-content/{id}

Returns a specific piece of custom content.

Update custom content

PUT /wiki/api/v2/custom-content/{id}

Update a custom content by id.

Delete custom content

DELETE /wiki/api/v2/custom-content/{id}

Delete a custom content by id.

Last updated

Was this helpful?