Project

General

Profile

Actions

Defect #12104

open

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

Added by Wim Bertels about 12 years ago. Updated about 12 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
REST API
Target version:
-
Start date:
Due date:
% Done:

10%

Estimated time:
Resolution:
Affected version:

Description

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>'\
                '<name>snr1234name</name>'\
                '<identifier>snr1234id</identifier>'\
                '<description>Alleen om te testen</description>'\
           '</project>'

print(test_xml)

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

print(url_met_key)

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

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

log:

Processing WelcomeController#index (for 127.0.1.1 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:

#!/bin/sh

curl -k -H "Content-Type: application/xml" -X POST --data "@project.xml" 
https://thesame.server/projects.xml?key=somevalidkeyfrommanagerwithrighttocreate

wich results in a auth problem:

Processing ProjectsController#add to xml (for 127.0.1.1 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 [https://validserver.org/projects.xml?key=validkey]

Suggestions?

I would change the wiki page:
http://www.redmine.org/projects/redmine/wiki/Rest_api
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 ?

Info:

# 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

Actions

Also available in: Atom PDF