Created
February 28, 2020 11:52
-
-
Save brettmillerb/0826765b89cc46ba88843b7dd033c5d7 to your computer and use it in GitHub Desktop.
ServiceNow Sys_User
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Eg. User name="admin", Password="admin" for this code sample. | |
$user = "admin" | |
$pass = "admin" | |
# Build auth header | |
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user, $pass))) | |
# Set proper headers | |
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" | |
$headers.Add('Authorization', ('Basic {0}' -f $base64AuthInfo)) | |
$headers.Add('Accept', 'application/json') | |
$headers.Add('Content-Type', 'application/json') | |
# Specify endpoint uri | |
$uri = "https://dev93198.service-now.com/api/now/table/sys_user" | |
# Specify HTTP method | |
$method = "post" | |
$body = @{ | |
name = 'Shawn Melton' | |
first_name = 'Shawn' | |
last_name = 'Melton' | |
email = 'shawn.melton@stuff.com' | |
} | |
$body = ConvertTo-Json -InputObject $body | |
# Send HTTP request | |
$response = Invoke-WebRequest -Headers $headers -Method $method -Uri $uri -Body $body | |
# Print response | |
$response.RawContent | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment