Skip to main content
Version: main

Get attachment file

Overview

Retrieves an attachment's file data by sys id.

Path parameters

NameDescription
sysIdThe sys id of the attachment.

Optional query parameters

N/A

Required query parameters

N/A

Examples

package main

import (
"context"
"fmt"
"log"
"os"

servicenowsdkgo "github.com/michaeldcanady/servicenow-sdk-go/v2"
attachmentapi "github.com/michaeldcanady/servicenow-sdk-go/v2/attachmentapi"
"github.com/michaeldcanady/servicenow-sdk-go/v2/credentials"
abstractions "github.com/microsoft/kiota-abstractions-go"
)

func main() {
// Step 1: Create credentials
cred := credentials.NewBasicProvider("{username}", "{password}")

// Step 2: Initialize client
client, err := servicenowsdkgo.NewServiceNowServiceClient(
servicenowsdkgo.WithAuthenticationProvider(cred),
servicenowsdkgo.WithURL("https://{instance}.service-now.com"),
)
if err != nil {
log.Fatal(err)
}

fileGetConfig := &attachmentapi.AttachmentItemFileRequestBuilderGetRequestConfiguration{
// Optional configurations
}

fileGetResponse, err := client.Now().Attachment().ByID("{SysID}").File().Get(context.Background(), fileGetConfig)
if err != nil {
log.Fatal(err)
}
}
Was this page helpful?