I'm trying to use python
to create a new ticket, but I can't make osticket
accept my API key.
Here is my code:
def post_ticket(json):
headers = {'API-Key': 'mykey'}
response = requests.post("http://mydomani.com/api/tickets.json", data=create_json_ticket(json), headers=headers)
for r in response:
print(r)
I'm getting error 'Valid API key required'
.
If I use the PHP
script given as example (using same url, key and JSON data) it works fine.
The header key should be "X-API-Key"
and not "API-Key"
.
From osTicket API
page:
HTTP Access
Access to the HTTP API is restricted to valid API keys. An X-API-Key HTTP header must be sent to indicate which API key is to be used with the request.
The API key must match the remote IP of the connected HTTP client. The remote IP is checked as usual. If the osTicket server is sitting behind a reverse proxy, the original IP of the client will be retrieved from the X-Forwarded-For header, if provided by your proxy.Example:
X-API-Key: BA00B76BAA30F62E1940B46CC1C3C73C
Command line Example with Curl:
curl -d "{}" -H "X-API-Key: BA00B76BAA30F62E1940B46CC1C3C73C" https://support.you.tld/api/tickets.json