Skip to main content
Version: v2.0

Create table record

Overview

Creates a single record in the specified table.

note

This endpoint doesn't support bulk insertion.

Path parameters

NameDescription
tableThe table name for the operation.

Optional query parameters

NameTypePossible valuesDescription
DisplayValuetableapi.DisplayValueDisplayValueTrue, DisplayValueFalse, or DisplayValueAllDetermines the type of data returned, either the actual values from the database or the display values of the fields.
ExcludeReferenceLinkboolN/AFlag that indicates whether to exclude Table API links for reference fields.
Fields[]string N/AList of fields to include in the response.
InputDisplayValueboolN/AFlag that indicates whether to set field values using the display value or the actual value.
Viewtableapi.ViewViewDesktop, ViewMobile, or ViewBothUI view for which to render the data.

Required query parameters

N/A

Examples

package main

import (
"context"
"fmt"
"log"

servicenowsdkgo "github.com/michaeldcanady/servicenow-sdk-go/v2"
tableapi "github.com/michaeldcanady/servicenow-sdk-go/v2/tableapi"
)

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
createConfig := &tableapi.TableRequestBuilderPostRequestConfiguration{
QueryParameters: &tableapi.TableRequestBuilderPostQueryParameters{
// Optional configurations
},
}

// Step 4: Build request body
createData := tableapi.NewTableRecord()
if err := createData.SetValue("short_description", "example incident"); err != nil {
log.Fatal(err)
}
if err := createData.SetValue("description", "incident created by servicenow-sdk-go"); err != nil {
log.Fatal(err)
}

// Step 5: Execute request
createResponse, err := client.Now().Table("{TableName}").Post(context.Background(), createData, createConfig)
if err != nil {
log.Fatal(err)
}
}
Was this page helpful?