๐Attachments
Get attachments
GET /wiki/rest/api/content/{id}/child/attachment
Returns the attachments for a piece of content. By default, the following objects are expanded: metadata.
package main
import (
"context"
"github.com/ctreminiom/go-atlassian/confluence"
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
"log"
"net/http"
"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 options = &models.GetContentAttachmentsOptionsScheme{
Expand: nil,
FileName: "",
MediaType: "",
}
attachments, response, err := instance.Content.Attachment.Gets(context.Background(), "76513281", 0, 50, options)
if err != nil {
if response != nil {
if response.Code == http.StatusBadRequest {
log.Println(response.CodeCode)
}
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
for _, attachment := range attachments.Results {
log.Println(attachment.Metadata.MediaType, attachment.Title)
}
}
Create or update attachment
PUT /wiki/rest/api/content/{id}/child/attachment
Adds an attachment to a piece of content. If the attachment already exists for the content, then the attachment is updated (i.e. a new version of the attachment is created).
Create attachment
POST /wiki/rest/api/content/{id}/child/attachment
Adds an attachment to a piece of content. This method only adds a new attachment. If you want to update an existing attachment, use Create or update attachments. package main
Last updated
Was this helpful?
