Page cover

๐ŸงบAttachments

Get attachment by id

GET /wiki/api/v2/attachments/{id}

Get returns a specific attachment

package main

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

	attachment, response, err := instance.Attachment.Get(context.Background(), "att219152391", 0, false)
	if err != nil {
		if response != nil {
			log.Println(response.Endpoint)
			log.Println(response.Code)
			log.Println(response.Bytes.String())
		}

		log.Fatal(err)
	}

	fmt.Print(attachment)
}

Get attachments by type

GET /wiki/api/v2/{custom-content-labels-pages-blogposts}/{id}/attachments

Gets returns the attachments of specific entity type.

  • You can extract the attachments for blog-posts,custom-contents, labels and pages

  • Depending on the entity type, the endpoint will change based on the entity type.

  • Valid entityType values: blogposts, custom-content, labels, pages

  • The number of results is limited by the limit parameter and additional results (if available) will be available through the next URL present in the Link response header.

Delete attachment

DELETE /wiki/api/v2/attachments/{id}

Delete an attachment by id.

Last updated

Was this helpful?