Defect #12104

REST API POST new project: malformed? or auth failure? Debian Stable Redmine

Added by Wim Bertels over 10 years ago. Updated over 10 years ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:


Category:REST API
Target version:-
Resolution: Affected version:1.0.1


I spent some time using the redmine REST API

Debian stable repository used, as distupgrades are important

short script with python:

#! /usr/bin/python

import string
import sys
import urllib
import urllib2
import ssl

#redmine REST connectie
test_xml =  '<project>'\
                '<description>Alleen om te testen</description>'\


top_level_url = "https://redmine.server.domain/" 
projects_xml_url = top_level_url + 'projects.xml'
key = '1234..key..1234'
url_met_key = projects_xml_url + '?key=' + key


req = urllib2.Request(top_level_url, test_xml)
req.add_header('Content-Type', 'application/xml')
response = urllib2.urlopen(req)
the_page =

Which resultes in a index request (ruby),
So probably my python code is wrong?
No errors though


Processing WelcomeController#index (for at 2012-10-15 18:05:21) [POST]
  Parameters: {"action"=>"index", "project"=>{"name"=>"snr1234name", "description"=>"Alleen om te testen", "identifier"=>"snr1234id"}, "controller"=>"welcome"}
Rendering template within layouts/base
Rendering welcome/index
Completed in 24ms (View: 12, DB: 5) | 200 OK [https://redmine.server.domain/]

Other examle trying to do the same with curl:


curl -k -H "Content-Type: application/xml" -X POST --data "@project.xml" 

wich results in a auth problem:

Processing ProjectsController#add to xml (for at 2012-10-15 18:10:31) [POST]
  Parameters: {"format"=>"xml", "action"=>"add", "project"=>{"name"=>"snr1234name", "description"=>"Alleen om te testen", "identifier"=>"snr1234id"}, "controller"=>"projects", "key"=>"validkey"}
Filter chain halted as [:authorize_global] rendered_or_redirected.
Completed in 11ms (View: 0, DB: 3) | 401 Unauthorized []


I would change the wiki page:
concerning project creating in version 1.0.1-2 using REST:
ie if nobody has a working example for creating projects using REST on redmine 1.0.1-2 ?


# dpkg -l | grep redmine
ii  redmine                             1.0.1-2                      flexible project management web application

# dpkg -l | grep postgresql
ii  postgresql                          8.4.13-0squeeze1             object-relational SQL database (supported version)

# ruby --version
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]

# rails --version
Rails 2.3.5


#1 Updated by Wim Bertels over 10 years ago

  • % Done changed from 0 to 10

The problem seems with the way ruby/redmine handles the request

A key authenticated GET request works (giving all the projects):

curl -k -H "Content-Type: application/xml" -X GET \

But a key authenticated POST request doenst work:

curl -k -H "Content-Type: application/xml" -X POST --data "@project.xml" \

Gives the error:

Processing ProjectsController#add to xml (for at 2012-10-16 13:05:01) [POST]
  Parameters: {"format"=>"xml", "action"=>"add", "project"=>{"name"=>"snr1234name", "description"=>"Alleen om te testen", "identifier"=>"snr1234id"}, "controller"=>"projects", "key"=>"akey"}
Filter chain halted as [:authorize_global] rendered_or_redirected.
Completed in 12ms (View: 0, DB: 3) | 401 Unauthorized [https://serverX/projects.xml?key=akey]

While a login/password POST request does work:

curl -k -H "Content-Type: application/xml" -X POST --data "@project.xml" \
-u loginY:passZ https://serverX/projects.xml


Also available in: Atom PDF