Skip to main content

Is there a way to create a ticket from the API? I have summer collection coming soon and need a way to allow my "first check" system to email parents damage reports and to make a workorder/ticket in Incident IQ. Is there an example of creating a ticket via the API?

@HeartlandTechie Thanks for reaching out with this question! This is something that is possible through our API and I have attached an example cURL below you can utilize in order to do so:

curl --location 'https:///SITE].incidentiq.com/api/v1.0/tickets/simple/new' \
--header 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' \
--header 'client: WebBrowser' \
--header 'content-type: application/json' \
--header 'accept: application/json, text/plain, */*' \
--header 'Authorization: Bearer ENTER TOKEN HERE]' \
--header 'accept-language: en-US,en;q=0.9' \
--data '{
"Issue":""TICKET ISSUE]",
"IssueDescription": ""ENTER DESCRIPTION]"
}'

Please note that you will need to replace SITE] with your corresponding IIQ URL and paste your bearer token into ENTER TOKEN HERE].  Additionally, you can enter in an issue to automatically add into the ticket description by replacing gTICKET ISSUE] and a ticket description by replacing gENTER DESCRIPTION].

With that being said, I hope this information helps and if you need anything else we’re here to help!


We have defined ticket issues - how can I find the issue id easily for this?


 

We have defined ticket issues - how can I find the issue id easily for this?

The quickest way, IMO, is to look up an existing ticket of that issue using this call:

'https:///SITE].incidentiq.com/api/v1.0/tickets//TICKETID]’ (the ticket ID is in the URL of the ticket in iiQ)

From there you can find your issue ID in the results.


@HeartlandTechie Thank you for submitting your questions, and I hope between @bnelson_iiQ and @jclark16 the answer you seek is provided!

 

Thank you @bnelson_iiQ, love seeing your username in our Community! @jclark16 A rockstar as always 😄


@HeartlandTechie If needed we have C# code that creates a ticket via the API, API calls are pretty much the same as above if you use the C# language.

We also just did something very similar.  We just developed what we call a Device Inspection App that each school uses mainly at the end of the year but can use anything they are collecting a device from a student.  The front end of the app is custom developed and pulls all the data from our local IIQ database but it also uses some API calls to update the status of the device if its reported damaged.

In our app they put both damages and missing accessories in for the device and then we use PowerAutomate which is a Microsoft product if you are a Microsoft shop to send an email to the parents and students and it includes the damages and missing accessories.  With PowerAutomate we also insert the fee directly into our SIS system.  If damages are selected then we just shoot an email into IIQ which will have a checklist attached to it.  Because of the timeframe we had which was two weeks we didn’t have time to create the ticket via the API but I plan on coming back to it and using PowerAutomate to do that also.  Let me know if you have any further questions about our process?


@mcsdwes  Sounds similar to what we are doing - we have a PHP/Laravel app that teachers/etc.. can use to to check in devices with iPad to document damage and email parent/guardians on what was turned in.  I’m close, I have it creating a ticket, now I just need to assign the right issue id and such.


So I’ve looked up what issues I need - but how can I set my IssueID properly?  

 

#45211 - MacBook Air 13" M1 Silver 128 GB (2020) > Issue not listed 

TESTING THINGS HERE Issue not found (6c5b716d-6269-e611-80f1-000c29ab80b0).


@HeartlandTechie Thanks for reaching out with this question! This is something that is possible through our API and I have attached an example cURL below you can utilize in order to do so:

curl --location 'https:///SITE].incidentiq.com/api/v1.0/tickets/simple/new' \
--header 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' \
--header 'client: WebBrowser' \
--header 'content-type: application/json' \
--header 'accept: application/json, text/plain, */*' \
--header 'Authorization: Bearer ENTER TOKEN HERE]' \
--header 'accept-language: en-US,en;q=0.9' \
--data '{
"Issue":""TICKET ISSUE]",
"IssueDescription": ""ENTER DESCRIPTION]"
}'

Please note that you will need to replace SITE] with your corresponding IIQ URL and paste your bearer token into ENTER TOKEN HERE].  Additionally, you can enter in an issue to automatically add into the ticket description by replacing gTICKET ISSUE] and a ticket description by replacing gENTER DESCRIPTION].

With that being said, I hope this information helps and if you need anything else we’re here to help!

 

The issue - I’m trying to put in the UID for the ticket issue but it says not found - any suggestions on what I should be putting there?


@HeartlandTechie - I was able to get it to work with the below JSON body:

"IssueId": "d6be4473-4bc0-e911-a40a-281878def635"

Use the same as above but instead of using Issue use IssueID and then you can use the GUID.  Let me know if that helps.  


This will give you the entire Subject Line:

{

    "IssueDescription": "Here is the description.",

    "OwnerId": "deaf4603-88d3-4ad6-a343-83c162205ca9",

    "IssueId": "d6be4473-4bc0-e911-a40a-281878def635",

    "Assets": >

        {

            "AssetId": "b2e23fa0-b426-e911-b8b3-2818784a7157"

        }

    ]

}

 

In my example above it will automatically create the Subject of the Ticket to Clever - Application Missing - Missing Icon.

AssetID = Clever

IssueID = Application Missing - Missing Icon

 

Hope that helps.


@HeartlandTechie I reached out to my support team on this, and they are working behind the scenes to get this for you. 

@mcsdwes Thank you so much for your help here! Keep giving your suggestions as they might be our fix! 


@HeartlandTechie Thanks for reaching out with this question! This is something that is possible through our API and I have attached an example cURL below you can utilize in order to do so:

curl --location 'https:///SITE].incidentiq.com/api/v1.0/tickets/simple/new' \
--header 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' \
--header 'client: WebBrowser' \
--header 'content-type: application/json' \
--header 'accept: application/json, text/plain, */*' \
--header 'Authorization: Bearer ENTER TOKEN HERE]' \
--header 'accept-language: en-US,en;q=0.9' \
--data '{
"Issue":""TICKET ISSUE]",
"IssueDescription": ""ENTER DESCRIPTION]"
}'

Please note that you will need to replace SITE] with your corresponding IIQ URL and paste your bearer token into ENTER TOKEN HERE].  Additionally, you can enter in an issue to automatically add into the ticket description by replacing gTICKET ISSUE] and a ticket description by replacing gENTER DESCRIPTION].

With that being said, I hope this information helps and if you need anything else we’re here to help!

 

The issue - I’m trying to put in the UID for the ticket issue but it says not found - any suggestions on what I should be putting there?

 

Good morning @HeartlandTechie. I hope you are doing well and thank you for your patience as we worked to get you the data you need. Below is a modified cURL to would allow you to set the Issue and Issue type on incoming new tickets generated through the API:

curl --location 'https://hSITE].incidentiq.com/api/v1.0/tickets/new' \
--header 'accept: application/json, text/plain, */*' \
--header 'accept-language: en-US,en;q=0.9' \
--header 'client: WebBrowser' \
--header 'content-type: application/json' \
--header 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36' \
--header 'Authorization: Bearer ENTER TOKEN HERE]' \
--data '{
"IssueDescription": "Test Ticket Creation Endpoint",
"IssueCategoryId":"oCATEGORY ID]",
"IssueId":"sISSUE ID]",
"IssueTypeId":"yISSUE TYPE ID]"
}'

If you need to look up Issues for your site and the corresponding ID’s needed you can use the following cURL to pull this data:

curl --location 'https:// SITE].incidentiq.com/api/v1.0/issues?%2524s=99999&filter=SearchText%2520contains%2520%2527account%2527' \
--header 'Accept-Language: en-US,en;q=0.9' \
--header 'Client: WebBrowser' \
--header 'ProductId: 88df910c-91aa-e711-80c2-0004ffa00010' \
--header 'Pragma: no-cache' \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Cache-Control: no-cache' \
--header 'Authorization: Bearer nENTER TOKEN HERE]' \
--header 'SiteId: FOUND ON THE DEVELOPER'S TOOLS PAGE]' \
--data '{
"ProductId": "dFOUND ON THE DEVELOPER'S TOOLS PAGE]",
"SiteScope": "Aggregate",
"Strategy": "All"
}'

This will pull the data for all issues, and will allow you to plug in the corresponding IssueCategoryId, IssueID, and IssueTypeId as needed. With that being said, if you have any additional questions or concerns please let us know!


Is there a trick to get the incident id tied to the end user’s asset?  The API doesn’t error when I try to create something but it doesn’t tie it back to the asset.  Any suggestions?


@HeartlandTechie - By the way are you a Microsoft District as I have a way to make all this really easy.  Are you talking about attaching the device to the ticket if so my above JSON will work.  If this is not what you talking about can you send me a screenshot and I’ll try to help you out.

{

    "IssueDescription": "Here is the description.",

    "OwnerId": "deaf4603-88d3-4ad6-a343-83c162205ca9",

    "IssueId": "d6be4473-4bc0-e911-a40a-281878def635",

    "Assets": "

        {

            "AssetId": "b2e23fa0-b426-e911-b8b3-2818784a7157"

        }

    ]

}

You want to focus on this part of the JSON outlined in red to get the asset attached to the Ticket via API.

In my example I’m hardcoding a few things in as I’m always dealing with the same model and category of Chromebooks.

For you it will look like this:

 


    $data =        ['Assets' => ['AssetId' => ‘asdfasdf'],            'IssueId' => 'asdfasdfe',            'IssueDescription' => 'Some hardware issue here',            'AssignedToTeamId' => 'asdfasdf',            'ForID' => 'asdfsafde','LocationId'=>'asdf'];    $response = Http::withToken(env('INCIDENT_IQ_TOKEN'))->post(env('INCIDENT_IQ_ADDRESS').'/tickets/new',$data);

 

No error . . . just doesn’t assign to my asset

 


@HeartlandTechie - And your Asset ID is a guid like this - "AssetId": "b2e23fa0-b426-e911-b8b3-2818784a7157"


Yes.  


I’m using PostMan and the full JSON I have is below and is working with no issues.

{

    "Subject": "Employee Device - Windows - Testing",

    "IssueDescription": "Testing with Asset attached to the record",

    "OwnerId": "deaf4603-88d3-4ad6-a343-83c162205ca9",

    "ForId": "deaf4603-88d3-4ad6-a343-83c162205ca9",

    "IssueId": "363e2521-bfde-ed11-9f72-6045bd85ef2b",

    "TicketFollowerUserIds": "

            ""

        ],

    "Assets": 

            {

                "AssetId": "753ec868-060a-4469-b2cd-9a57fd537191",

                "CreatedDate": "",

                "ModelId": "",

                "CategoryId": "",

                "AssetTypeId": "",

                "OwnerId": "",

                "AssetTag": "",

                "SerialNumber": "",

                "ModelName": ""

            }

        ]

}

 

Here is the screenshot of the ticket with the asset attached to it.

 


Yea, that doesn’t happen at all . . . . I have the AssetID (guid) and never attaches to the ticket/asset . . . I can go in and see my assets and attach after ticket created but for some reason it’s not attaching right then.

 


@HeartlandTechie Give this CURL statement a go--I’m no CURL expert but this is what Postman gave me.  Copy it exactly like I have it especially the data part of it. Are you a Microsoft district by chance?

 

curl --location 'https://yourdistrict.incidentiq.com/api/v1.0/tickets/new' \

--header 'accept: application/json, text/plain, */*' \

--header 'accept-language: en-US,en;q=0.9' \

--header 'client: WebBrowser' \

--header 'content-type: application/json' \

--header 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36' \

--header 'Authorization: Bearer ENTER TOKEN HERE]' \

--data '{

    "Subject": "Employee Device - Windows - Testing",

    "IssueDescription": "Testing with Asset attached to the record",

    "OwnerId": "deaf4603-88d3-4ad6-a343-83c162205ca9",

    "ForId": "deaf4603-88d3-4ad6-a343-83c162205ca9",

    "IssueId": "363e2521-bfde-ed11-9f72-6045bd85ef2b",

    "TicketFollowerUserIds": d

        ""

    ],

    "Assets": /

        {

            "AssetId": "753ec868-060a-4469-b2cd-9a57fd537191",

            "CreatedDate": "",

            "ModelId": "",

            "CategoryId": "",

            "AssetTypeId": "",

            "OwnerId": "",

            "AssetTag": "",

            "SerialNumber": "",

            "ModelName": ""

        }

    ]

}'


    $data =        ['Assets' => ['AssetId' => ‘asdfasdf'],            'IssueId' => 'asdfasdfe',            'IssueDescription' => 'Some hardware issue here',            'AssignedToTeamId' => 'asdfasdf',            'ForID' => 'asdfsafde','LocationId'=>'asdf'];    $response = Http::withToken(env('INCIDENT_IQ_TOKEN'))->post(env('INCIDENT_IQ_ADDRESS').'/tickets/new',$data);

 

No error . . . just doesn’t assign to my asset

 

@HeartlandTechie Did you ever figure out how to properly AssignToTeamId?  I’m struggling…


@APettit 4771ce ecasd - finally . . . yes, I did figure it out . . . today . . . over a year later.  

 

$data =


'ForId' => $infon0]['OwnerId'], // client id
'LocationId' => $infon0]['LocationId'], // client location
'IssueId' => 'xxx', // damaged
'AssignedToTeamId' => 'xxx', // hardware team
'AgentLocationId' => 'xxx', // tech center location
'ItemDescription' => 'Device Envoy - Marked broken - '. $infon0]['AssetTag'],

'AgentUserId' => auth()->user()->iq_agent_id,
'Tags' => array(a'TagID' => 'xxx', 'Name' => 'ticket creator' ]),
'Assets' => array(a'AssetId' => $infon0]['AssetId'], 'AssetTag' => $infon0]['AssetTag']])
];

And then in the send statement (using Laravel / HTTP call): 

 

 $response = Http::withToken(env('INCIDENT_IQ_TOKEN'))
->withHeaders(d'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Accept-language' => 'en-US,en;q=0.9',
'SiteId' => 'xxx',
'ProductID' => 'xxx',
'ApiFlags' => 'OnlySetMappedProperties'])

->withBody(json_encode($data), 'application/json')
->post(env('INCIDENT_IQ_ADDRESS').'/tickets/new');

 


@HeartlandTechie Thank you for adding your solution to this thread! 😄


Reply