BMSVieira / osticket-api

OSTicket Unofficial API
MIT License
29 stars 11 forks source link

Incorrect API Format - HTTP/1.0 500 Internal Server Error - Incorrect API Format #20

Closed pgaben closed 6 months ago

pgaben commented 6 months ago

I would like to create a ticket, but I can't seem to do it. osTicket (1.18-git)

/etc/apach2/osticket.conf

<VirtualHost *:80> ServerName 10.90.80.50 DocumentRoot /var/www/html/osTicket/upload

<Directory /var/www/html/osTicket> AllowOverride All

ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined

ost_wbs folder is located at /var/www/html/osTicket/ost_wbs

If I use X-API-KEY, I get {"status":"Error","data":"Incorrect API Format"} If I use apikey: HTTP/1.0 500 Internal Server Error

curl -v -X POST "http://10.90.80.50/ost_wbs/" -H "X-API-KEY: C0000000000000000000000000000000" -d '{ "query":"ticket", "condition":"add", "parameters":{ "title":"Titulo do Ticket", "subject":"Subject do Ticket", "user_id": 2, "priority_id":2, "status_id":1, "dept_id":1, "sla_id":1, "topic_id":1, "ip": 127.0.0.1 } }'

Note: Unnecessary use of -X or --request, POST is already inferred.

Trying 10.90.80.50:80... Connected to 10.90.80.50 (10.90.80.50) port 80 (#0) POST /ost_wbs/ HTTP/1.1 Host: 10.90.80.50 User-Agent: curl/7.81.0 Accept: / X-API-KEY: C0000000000000000000000000000000 Content-Length: 237 Content-Type: application/x-www-form-urlencoded

Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Date: Tue, 07 May 2024 07:35:09 GMT < Server: Apache/2.4.52 (Ubuntu) < Content-Length: 48 < Content-Type: application/json; charset: ut-8 < Connection #0 to host 10.90.80.50 left intact {"status":"Error","data":"Incorrect API Format"} curl -v -X POST "http://10.90.80.50/ost_wbs/" -H "apikey: C0000000000000000000000000000000" -d '{ "query":"ticket", "condition":"add", "parameters":{ "title":"Titulo do Ticket", "subject":"Subject do Ticket", "user_id": 2, "priority_id":2, "status_id":1, "dept_id":1, "sla_id":1, "topic_id":1, "ip": 127.0.0.1 } }'

This is the response:

Trying 10.90.80.50:80... Connected to 10.90.80.50 (10.90.80.50) port 80 (#0) POST /ost_wbs/ HTTP/1.1 Host: 10.90.80.50 User-Agent: curl/7.81.0 Accept: / apikey: C0000000000000000000000000000000 Content-Length: 237 Content-Type: application/x-www-form-urlencoded

Mark bundle as not supporting multiuse HTTP 1.0, assume close after body < HTTP/1.0 500 Internal Server Error < Date: Tue, 07 May 2024 06:22:24 GMT < Server: Apache/2.4.52 (Ubuntu) < Content-Length: 0 < Connection: close < Content-Type: application/json; charset: ut-8 < Closing connection 0

BMSVieira commented 6 months ago

Hey, thank you for posting. Assuming that you are getting this error.

From the error log you provided, Its pretty obvious that theres a problem with your API Key and its returning a "Incorrect API Format" message.

"apikey: C0000000000000000000000000000000"

pgaben commented 6 months ago

The apikey was just an example, I am using the system's API: "apikey: CAA96039510BBAB23F4C5F16D456F754"