Delete attachment
Overview
Delete specific attachment using the sys id.
Path parameters
| Name | Description |
|---|---|
sysId | The sys id of the attachment. |
Optional query parameters
N/A
Required query parameters
N/A
Examples
- Fluent
- Standard
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)
}
}
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: Define raw URL
rawURL := "https://{instance}.service-now.com/api/now/attachment/{SysID}"
// Step 4: Configure request
deleteConfig = &attachmentapi.AttachmentItemRequestBuilderDeleteRequestConfiguration{
// Optional configurations
}
// Step 5: Build request
collectionRequestBuilder := attachmentapi.NewAttachmentItemRequestBuilder(rawURL, client.GetRequestAdapter())
if err := collectionRequestBuilder.Delete(context.Background(), deleteConfig); err != nil {
log.Fatal(err)
}
}