I am having problems with a simple script whose sole purpose is to create a single ticket and every time I get
401 Credentials Required
I took my code verbatim from https://github.com/z4r/python-rtkit . (URL, username and password are edited for security reasons)
from rtkit.resource import RTResource
from rtkit.authenticators import BasicAuthenticator
from rtkit.errors import RTResourceError
from rtkit import set_logging
import logging
set_logging('debug')
logger = logging.getLogger('rtkit')
resource = RTResource('http://rt.example.com/REST/1.0/', 'user', 'pass', BasicAuthenticator)
content = {
'content': {
'Queue': 'General - unassigned',
'Subject' : 'Test Ticket Python',
}
}
try:
response = resource.post(path='ticket/new', payload=content,)
logger.info(response.parsed)
except RTResourceError as e:
logger.error(e.response.status_int)
logger.error(e.response.status)
logger.error(e.response.parsed)
Here is the conclusion I get from this
[DEBUG] POST ticket/new
[DEBUG] {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'Accept': 'text/plain'}
[DEBUG] 'content=Queue: General - unassigned\nSubject: Test Ticket Python'
[INFO] POST
[INFO] http:
[DEBUG] HTTP_STATUS: 200 OK
[DEBUG] 'RT/3.6.6 401 Credentials Required\n'
[DEBUG] RESOURCE_STATUS: 401 Credentials required
[INFO] []
[INFO] []
Does anyone know how to fix this? I just need to be able to make tickets using python. Thus, as an alternative, other ways of doing this that do not use python-rtkit are great if they achieve the ultimate goal.
EDIT: Opening the URL of my browser (after logging in) gives
RT/3.6.6 200 Ok
id: index.html
Opening the URL of my browser (before logging in) gives
RT/3.6.6 401 Credentials Required
- , , . , Cookie - .
EDIT:
@Zaroth . https.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://rt.example.com/REST/1.0/">here</a>.</p>
<hr>
<address>Apache/2.2.3 (Red Hat) Server at rt.hdms.com Port 80</address>
</body></html>