osticket, create ticket through REST API
Asked Answered
S

3

11

I'm trying to create a ticket in osticket through its REST API (https://github.com/osTicket/osTicket-1.7/blob/develop/setup/doc/api/tickets.md)

The problem is /api/tickets.json returns 404. I have it installed in a server on osticket folder (something like http://my.net.work.ip/osticket/api/tickets.json - 404)

Also, I've tried to CURL the server (logged in through ssh), created an APIKey for the server's IP address and had the same response.

What am I missing here? Thank you

Systematism answered 8/5, 2014 at 10:58 Comment(0)
S
16

So, I had to add http.php after api/ (/api/http.php/tickets.json) and now I can create tickets.

Check http://tmib.net/using-osticket-1812-api. The sample used has this info in the comments.

enter image description here

The two really important parts are on lines 18 and 19.

'url'=>'http://your.domain.tld/api/http.php/tickets.json', // URL to site.tld/api/tickets.json
'key'=>'PUTyourAPIkeyHERE' // API Key goes here
//Edit line 18 to have your URL.
//Edit line 19 by changing "PUTyourAPIkeyHERE" to your API key (aka the "THISISAFAKEAPIKEYHERE!" from earlier).
Systematism answered 8/5, 2014 at 11:31 Comment(2)
how to create user via api?Colossal
@ivan Lewis You can use a plugin for external authentication...github.com/osTicket/core-pluginsDodd
D
2

The piece that seems to be missing from the docs is how to pass the API key. Through a bit of testing and the script mentioned above, I found the X-API-Key header. That means you can create tickets without using a script, you can use curl as easily as:

curl -X POST -H "X-API-Key: 1234567890ABCDEF" -v -d'{"autorespond":false, "source": "API", "name": "Doctor Who", "email":"[email protected]", "subject":"Have you seen my Tardis key?", "message":"I have managed to lock myself out of the Tardis, can you send me a spare key?"}' http://support.gallifrey.org/api/tickets.json

This will only work if it is run from the IP address you specified when you created the API key.

Dutcher answered 25/8, 2016 at 21:24 Comment(0)
L
1

Besides changing lines 18 and 19 you need to make sure that you have the correct IP address. You can check that by going to your site here: http://your.domain.tld/support/scp/logs.php

Then look to see if you get the error API Error (401). If you do then look at the IP address and create a new API key for that IP address.

The problem I was facing was I typed in my IPv4 address, but the server was getting my IPv6 address.

Lard answered 25/2, 2016 at 4:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.