Skip to main content
Version: main

Get attachment

Overview

Retrieve specific attachment metadata using the 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)
}

getItemConfig := &attachmentapi.AttachmentItemRequestBuilderGetRequestConfiguration{
// Optional configurations
}

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