Jump to content

Recommended Posts

Posted

I'm hoping this is something easy I'm overlooking when it comes to attaching a file to logging a ticket via the API, per the "Entity API / LogIncident" it states as an input "fileName" as string (should mention array(string) in my opinion) with a description of "The full path for the file(s) to be attached." Based on this I would assume the path to the WebDav session location, or is this a different location? I've tried a couple of different methods for the file reference, in all cases the ticket is created without issue and no returned errors or warnings but no attachment. I did manage to attach a file but required another API call via "attachFileFromSession" which did work, and I can go this route if it's not possible to attach the file at time of ticket creation.

Here is the code I used as of my last test, much appreciated for any assistance.

# CREATE A TICKET
$FileAttachment = @{
	filename = "/session/Ab.pdf"
	description = "This is a file"
	visibility = "TrustedGuest"
}
$FJson = ($FileAttachment | ConvertTo-Json)

$Endpoint = "https://mdh-p01-api.hornbill.com/demo/xmlmc/apps/com.hornbill.servicemanager/Requests"
$Body = @{
	"@service" = "apps/com.hornbill.servicemanager/Incidents"
	"@method" = "logIncident"
	params = @{
		summary = "Iphone 17 is bat shit crazy"
		#description = ""
		requestType = "Incident"
		# customerId = "xs:string"
		# customerType = "xs:string"
		# ownerId = "xs:string"
		# teamId = "xs:string"
		# status = "xs:string"
		# priorityId = "xs:string"
		# categoryId = ""xs:string""
		# categoryName = "xs:string"
		# image = "xs:string"
		# sourceType = "xs:string"
		# sourceId = "xs:string"
		# assetId = "xs:string"
		# impact = "xs:string"
		# urgencyId = "xs:string"
		serviceId = "15"
		# questions = $Qjson
		# resolutionDetails = "xs:string"
		fileName = @($Fjson)
		# siteId = "xs:string"
		# siteName = "xs:string"
		# catalogId = "xs:string"
		# catalogName = "xs:string"
		# externalRefNumber = "xs:string"
		bpmName = "mobile-issue"
		# questionFieldMap = 
		# senderDetails = "xs:string"
		# ccDetails = "xs:string"
		# connectionMap = "xs:string"
		# connectionUpdateTimeline = "xs:boolean"
		# connectionTimelineVisibility = "xs:string"
		# employeeAssignmentUserId = "xs:string"
		# employeeAssignmentNumber = "xs:string"
	}
}
$Header = @{
	"Authorization" = "ESP-APIKEY XXXXXXXXXXXXXXXXXXXXX"
}
$Parameters = @{
	Method      = "POST"
	Uri         = $Endpoint
	Headers     = $Header
	Body        = ($Body | ConvertTo-Json)
	ContentType = "application/json"
}
$CaptureTicket = Invoke-RestMethod @Parameters
$CaptureTicket.params.requestId

 

Posted
1 hour ago, SamS said:

Hi @William Weiszbrod,

We are in the process or re-doing all our documentation, but you might want to follow the final link in this article: https://wiki.hornbill.com/index.php?title=XMLMC_API_Quickstart#FAQs

@SamS Are you referencing this article?: https://wiki.hornbill.com/index.php?title=XMLMC_API_File_Upload_Sample

if so then I have a PowerShell script using the concepts based on the article, I was hoping to add the file when calling "Entity API / logIncident", it's implied it's possible based on the parameters listed here: https://docs.hornbill.com/servicemanager-api-api/entities/incidents/espflowcodeentityoperation/content/logincident

image.png.edc61a8fe89373c2c738aae16a98d168.png

Now if it turns out this isn't possible I do at least have my current working method, I just wanted to limit my API calls from 3 to 2. Currently I POST for the ticket creation, I PUT for the file upload, and end with another POST to attach the uploaded file to the created ticket. By end of year we will be creating 50+ tickets for contract extensions and  need to track each person by a ticket, instead of manually creating each one be great to just automate the creation of them all. I just want to be kind to the API and limit the number of actions.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...