Delete attachment¶
Overview¶
Delete specific attachment using the sys id.
Path parameters¶
| Name | Description |
|---|---|
baseurl |
The absolute base URI for the request (this is the same for all requests) including: the schema, the domain, and a path fragment. |
sysId |
The 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"
attachmentapi "github.com/michaeldcanady/servicenow-sdk-go/attachment-api"
"github.com/michaeldcanady/servicenow-sdk-go/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.Now2().Attachment2().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"
attachmentapi "github.com/michaeldcanady/servicenow-sdk-go/attachment-api"
"github.com/michaeldcanady/servicenow-sdk-go/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://https://{instance}.service-now.com/api/now/attachment/{SysID}"
// Step 4: Configure request
deleteConfig = &attachmentapi.AttachmentItemRequestBuilderDeleteRequestConfiguration{
// Optional configurations
}
// Step 5: Build request
collectionRequestBuilder := attachmentapi.NewAttachmentItemRequestBuilder2(rawURL, client.RequestAdapter)
if err := collectionRequestBuilder.Delete(context.Background(), deleteConfig); err != nil {
log.Fatal(err)
}
}