I just migrated to another VPS and moved from version 1.10 to v1.11. Everything works except the ticket API. Though I have the correct sending server's IP address set for my API key I get this in the logs...

API Error (401)
Valid API key required

The API key is correct and the sender's IP address matches the IP for the API key. I have exactly the same configuration as I did before the migration. I tried adding a new API key to no avail.

I originally though it had something to do with a failure of mod_rewrite because I see 'URL Not Supported' when navigating to the end point with a browser: https://github.com/osTicket/osTicket/issues/4148#issuecomment-479714286

However, The fact that my error message references an invalid API key coupled with the fact that OST is logging the IP address of the requester, this probably isn't the case.

EDIT:
If I disable API key validation, the tickets are created normally, so the issue is with key validation.

Please help us to help you by reading and following the posting guidelines located in this thread: Please read before requesting assistance. The more information you give us the better we will be able to assist you. Thank you.

Environment details?

Sorry, here is my system info...

System error logs...

/var/log/apache2/error.log contains no pertinent information.

Here is the code I use...

2 years later

how you solved the error. It happens the same to me. thanks

Never go a response here so I just left API validation disabled.

a year later

I still have this issue on version 1.15

To disable the API validation for tickets, disable these two lines in includes/api.ticket.php

if(!($key=$this->requireApiKey()) || !$key->canCreateTickets())
return $this->exerr(401, __('API key not authorized'));

a year later

If you use Cloudflare which change your IP each request, here is how you can still check for a valid API KEY, but avoid the IP check.

include/class.api.php

Original
201: elseif (!$key->isActive() || $key->getIPAddr() != $this->getRemoteAddr())
212: $this->key = API::lookupByKey($key, $ip);

Change to
201: elseif (!$key->isActive())
212: $this->key = API::lookupByKey($key, false);

Write a Reply...