API Call through powershell/vbs

Khozema Attar1
Tera Guru

Hello experts,

Is there   an API Key/call we could use to pull data from Service now, specifically just tickets/incidents per user.     Either via Powershell/vbs or PHP?

If it is possible can I have some links which could guide me in a proper direction?

Thanks

5 REPLIES 5

For example:



# 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')




# Specify endpoint uri


$uri = "https://instance_name.service-now.com/api/now/stats/incident?sysparm_query=sys_created_onBETWEENjava..."



# Specify HTTP method


$method = "get"




{request.body ? "$body = \"" :""}}



# Send HTTP request


$response = Invoke-WebRequest -Headers $headers -Method $method -Uri $uri



# Print response


$response.RawContent