API v3 Add Attachment To Ticket
This is the code that I have cobbled together based on various resources, such as the public beta documentation and the API documentation in my tenant.
- $ApiKey = "API-KEY-GOES-HERE" # Technician API Key
- $SdpUri = "https://servicedesk.contoso.com"
- $RequestID = "111111"
- $input = @"
- {
- "attachment": {
- "filename": "@C:\temp\test.txt",
- "addtoattachment": true,
- }
- }
- "@
- $header = @{TECHNICIAN_KEY=$ApiKey}
- $params = @{input_data=$input;format='json'}
- $Uri = $SdpUri + "/api/v3/$RequestID/attachment"
- $result = Invoke-RestMethod -Method GET -Uri $Uri -Headers $header -Body $params -ContentType "application/x-www-form-urlencoded"
- $result
Could someone please point me in the right direction as to formatting my JSON input? I have a separate script that I am able to get attachments with but I would like to be able to add an attachment to an existing ticket. Currently I am receiving a status_code 4007 "failed" when attempting to run the above code.
New to ADSelfService Plus?