Skip to main content
Version: v2.0

Delete attachment

Overview

Delete specific attachment 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)
}

// Step 3: Configure request
deleteConfig := &attachmentapi.AttachmentItemRequestBuilderDeleteRequestConfiguration{
// Optional configurations
}

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