Тёмный

Upload a file from your PC/server to ServiceNow through Powershell API 

Ranjan Financials
Подписаться 231
Просмотров 1,3 тыс.
50% 1

This video demonstrates how can we upload a file from server to the Service-Now instance through Powershell API call.
#RESTAPIServiceNow
#PowershellServiceNow
#ServiceNowIntegration
Code:
#variables
$user, $pass, $env = 'admin', '**********, 'dev118854'
$file_path = "C:\temp\test.csv"
#Headers
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user, $pass)))
$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')
function readinc(){
$incident = Read-Host "Enter the Incident Number:"
$uri = ""+ $env + ".service-now.com/api/now/table/incident?sysparm_query=number%3D" + $incident + "&sysparm_display_value=true&sysparm_limit=1"
$method = "get"
$response = Invoke-RestMethod -Headers $headers -ContentType "application/json" -Method $method -Uri $uri
#$response.result
$sys_id = $response.result.sys_id
return $sys_id
}
function updateincattchmt(){
$inc_sys_id = readinc
$attachUri = ""+ $env + ".service-now.com/api/now/attachment/file?table_name=incident&table_sys_id=" + $inc_sys_id + "&file_name=" + $file_path
$upload= Invoke-RestMethod -Headers $headers -Uri $attachUri -Method Post -InFile $file_path -ContentType 'multipart/form-data'
if($?){
echo "File Upload Successful"
}
}
updateincattchmt

Опубликовано:

 

6 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 9   
Далее
Python Paramiko Module
23:49
Просмотров 6 тыс.
Creating a Data Source in ServiceNow
15:41
Просмотров 10 тыс.
PUBG MOBILE | Metro Royale: Fun Moments #4
00:16
Просмотров 144 тыс.
Servicenow - Sending file to Mid server
12:53
Просмотров 6 тыс.
The Basics of Payroll for UK Business Owners
10:00
Просмотров 6 тыс.
ServiceNow Integration with Python to Read/Update RITM
17:26