I'm a PowerShell scripter that has done a couple of things to automate opening/closing tickets for our agency. Currently, we have a script that lets our techs quickly create tickets (some open, some closed) for phone calls they receive. To give a quick look at what we're doing, we first initialize a bunch of variables that have already been determined, such as $Subject, $Details, $Tech, and $PhoneInUser.
##Host Information##
$url = $sdphost + "sdpapi/request"
$method = "POST"
$operation = "ADD_REQUEST"
##Ticket Details##
$inputdata = @"
{
"operation": {
"details": {
"requester": "$PhoneInUser",
"subject": "$Subject",
"description": "$Details",
"Requesttemplate": "Other (Internal)",
"priority": "Priority 3",
"group": "Service Desk",
"technician": "$Tech",
"Mode": "Phone Call",
"Impact": "Single User",
"Urgency": "Low",
"Category": "$Category",
"Subcategory": "$SubCat",
"Item": "$Item",
"CREATEDBY": "$Tech",
"service": "Service Request",
"FCR": "true",
"Tracker": "$Tech"
}
}
}
"@
##Ties the API info and settings all together##
$params=@{INPUT_DATA=$inputdata;OPERATION_NAME=$operation;TECHNICIAN_KEY=$Techkey;format='json'}
$result = Curl -Uri $url -Method $method -Body $params
The line that I want to add at the end, after $result, is...
My main question is, how do I figure out what $RequestID is (the ticket number) here? It should be the ticket we just created, but I can't seem to figure our how to find that out prior to the ticket being created.
Any assistance would be greatly appreciated, as it may just be something simple I'm missing.
Thank you,
Travis West