Create table record¶
Overview¶
Creates a single record in the specified table.
Note: This endpoint doesn't support bulk insertion.
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. |
table |
The table name of for the operation. |
Optional query parameters¶
| Name | Type | Possible values | Description |
|---|---|---|---|
DisplayValue |
tableapi.DisplayValue |
TRUE, FALSE, or ALL |
Determines the type of data returned, either the actual values from the database or the display values of the fields. |
ExcludeReferenceLink |
bool |
N/A | Flag that indicates whether to exclude Table API links for reference fields. |
Fields |
[]string |
N/A | List of fields to include in the response. |
InputDisplayValue |
bool |
N/A | Flag that indicates whether to set field values using the display value or the actual value. |
View |
tableapi.View |
DESKTOP, MOBILE, or BOTH |
UI view for which to render the data. |
Required query parameters¶
N/A
Examples¶
package main
import (
"context"
"fmt"
"log"
"time"
servicenowsdkgo "github.com/michaeldcanady/servicenow-sdk-go"
"github.com/michaeldcanady/servicenow-sdk-go/credentials"
tableapi "github.com/michaeldcanady/servicenow-sdk-go/table-api"
)
func main() {
// Step 1: Create credentials
cred := credentials.NewUsernamePasswordCredential("{username}", "{password}")
// Step 2: Initialize client
client := servicenowsdkgo.NewServiceNowClient(cred, "{instance}.service-now.com")
// Step 3: Configure query parameters
params := &tableapi.TableRequestBuilderPostQueryParameters{
// Optional configurations
}
// Step 4: Build request body
data := map[string]string{
"short_description": "example incident",
"description": "incident created by servicenow-sdk-go",
}
// Step 5: Execute request
response, err := client.Now2().Table2("{TableName}").Post4(context.Background(), data, params)
if err != nil {
log.Fatal(err)
}
// Process response
}
package main
import (
"context"
"fmt"
"log"
"time"
servicenowsdkgo "github.com/michaeldcanady/servicenow-sdk-go"
"github.com/michaeldcanady/servicenow-sdk-go/credentials"
tableapi "github.com/michaeldcanady/servicenow-sdk-go/table-api"
)
func main() {
// Step 1: Create credentials
cred := credentials.NewUsernamePasswordCredential("{username}", "{password}")
// Step 2: Initialize client
client := servicenowsdkgo.NewServiceNowClient(cred, "{instance}.service-now.com")
// Step 3: Define path parameters
pathParameters := map[string]string{
"baseurl": "https://www.{instance}.service-now.com/api/now",
"table": "{TableName}",
}
// Step 4: Build request
requestBuilder := tableapi.NewTableRequestBuilder2(client, pathParameters)
// Step 5: Configure query parameters
params := &tableapi.TableRequestBuilderPostQueryParameters{
// Optional configurations
}
// Step 6: Build request body
data := map[string]string{
"short_description": "example incident",
"description": "incident created by servicenow-sdk-go",
}
// Step 7: Execute request
response, err := requestBuilder.Post4(context.Background(), data, params)
if err != nil {
log.Fatal(err)
}
// Process response
}