Trouble with the Python API while creating projects.
Added by Keyser Soze over 11 years ago
My code looks something like this...
I cant figure out what I must be doing wrong, is there something else I should import?
----------------------------------------
- Import the Redmine class
from redmine import Redmine
server = Redmine('http://localhost/redmine', username='Admin', password='xxxx')
project = server.projects.new(id=4, subject="Test from Python", description="That rabbit is dynamite!")
print "This program is done! "
--------------------------------
And this throws the below errors:
----------------------------------
C:\Python27>python C:\Python27\Python\CreateProject.py
Traceback (most recent call last):
File "C:\Python27\Python\CreateProject.py", line 7, in <module>
project = server.projects.new(id=4, subject="Test from Python", description=
"That rabbit is dynamite!")
File "build\bdist.win32\egg\redmine\redmine_rest.py", line 489, in new
File "build\bdist.win32\egg\redmine\redmine_rest.py", line 680, in post
File "build\bdist.win32\egg\redmine\redmine_rest.py", line 666, in open
File "build\bdist.win32\egg\redmine\redmine_rest.py", line 658, in open_raw
File "C:\Python27\lib\urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 406, in open
response = meth(req, response)
File "C:\Python27\lib\urllib2.py", line 519, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python27\lib\urllib2.py", line 438, in error
result = self._call_chain(*args)
File "C:\Python27\lib\urllib2.py", line 378, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 890, in http_error_401
url, req, headers)
File "C:\Python27\lib\urllib2.py", line 865, in http_error_auth_reqed
response = self.retry_http_basic_auth(host, req, realm)
File "C:\Python27\lib\urllib2.py", line 878, in retry_http_basic_auth
return self.parent.open(req, timeout=req.timeout)
File "C:\Python27\lib\urllib2.py", line 406, in open
response = meth(req, response)
File "C:\Python27\lib\urllib2.py", line 519, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python27\lib\urllib2.py", line 444, in error
return self._call_chain(*args)
File "C:\Python27\lib\urllib2.py", line 378, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 527, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 422: Unprocessable Entity
Replies (1)
RE: Trouble with the Python API while creating projects.
-
Added by Keyser Soze over 11 years ago
Hey guys.. I know I asked this question above and I can understand how I may be coming across as a n00b...I wanted to reach out to this group and provide some context to what I am looking for again:
I am NOT looking for someone to handhold me through all of this
Because the same code structure works for creating Issues, I would imagine this would work for creating projects. So maybe I can simplify my question so anyone reading this can give a short answer instead of a long drawn 'debug' chain..so please help me choose from one of the possible responses
1. You are on the right track, you are probably missing a library or path
2. I have created projects and do so all the time via an API, just not the Python API, go try this [insert 'this' here]
3. You cannot create projects with the API
Hopefully this makes it a bit simpler. BTW I am on Redmine 2.2.2.stable