Get attachment¶
Overview¶
Retrieve specific attachment metadata 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)
}
get_item_config := &attachmentapi.AttachmentItemRequestBuilderGetRequestConfiguration{
// Optional configurations
}
get_item_response, err := client.Now2().Attachment2().ByID("{SysID}").Get(context.Background(), get_item_config)
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
get_item_rawURL := "https://https://{instance}.service-now.com/api/now/attachment/{SysID}"
// Step 4: Configure request
get_item_std_config := &attachmentapi.AttachmentItemRequestBuilderGetRequestConfiguration{
// Optional configurations
}
// Step 5: Build request
get_item_builder := attachmentapi.NewAttachmentItemRequestBuilder(get_item_rawURL, client.RequestAdapter)
get_item_std_response, err := get_item_builder.Get(context.Background(), get_item_std_config)
if err != nil {
log.Fatal(err)
}
}