https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292010-10-14T17:39:50ZRedmineRedmine - Defect #6667: REST API call with POST/PUThttps://www.redmine.org/issues/6667?journal_id=214142010-10-14T17:39:50ZFelix Schäfer
<ul></ul><p>Have you activated the REST API? What error are you getting from that command (use <code>-v </code> to see what HTTP error exactly your redmine returns)? What error does that call yield in the redmine log (<code>log/development.log</code> or <code>log/production.log</code>)?</p> Redmine - Defect #6667: REST API call with POST/PUThttps://www.redmine.org/issues/6667?journal_id=214362010-10-15T09:37:35ZAfsar Red
<ul></ul><p>Thanks for the quick response, Felix.</p>
<p>It gives the following error message, when I place verbose option.</p>
<p>.<br />.<br />.<br /><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><br /><html><head><br /><title>401 Authorization Required</title><br /></head><body><br /><h1>Authorization Required</h1><br /><p>This server could not verify that you<br />are authorized to access the document<br />requested. Either you supplied the wrong<br />credentials (e.g., bad password), or your<br />browser doesn't understand how to supply<br />the credentials required.</p><br /><hr><br /><address>Apache/2.2.14 (Ubuntu) Server at development.avonvoices.com Port 80</address><br /></body></html><br />.<br />.<br />.</p>
<pre><code>In the meantime, I could be able to get the list of projects by the following command using the same username and password:</code></pre>
<p>curl -u <a class="user active" href="https://www.redmine.org/users/52466">asami morita</a> -G <a class="external" href="http://host/projects.xml?key=">http://host/projects.xml?key=</a>......................................... -v</p>
<p>Thanks</p> Redmine - Defect #6667: REST API call with POST/PUThttps://www.redmine.org/issues/6667?journal_id=214802010-10-16T18:30:06ZHolger Just
<ul></ul><p>The REST API does <strong>not</strong> use your username and password via basic auth. Instead, each account has an assigned key (which you can find in the sidebar at <a class="external" href="http://yourredmine.com/my/account">http://yourredmine.com/my/account</a>. That key is used exclusively for authentication, as you have done in your second example. The username and password were ignored completely.</p> Redmine - Defect #6667: REST API call with POST/PUThttps://www.redmine.org/issues/6667?journal_id=215072010-10-18T09:23:01ZAfsar Red
<ul></ul><p>Holger, <br /> Thanks for the followup. <br />From the documentation(<a class="external" href="http://www.redmine.org/wiki/redmine/Rest_Projects">http://www.redmine.org/wiki/redmine/Rest_Projects</a>), I found that, it could be able create a project by the following command:</p>
<p>curl -X POST -d '<?xml version="1.0" encoding="UTF-8"?><project><name>Redmine</name><identifier>redmin</identifier><description>Redmine is a flexible project management web application written using Ruby on Rails framework.</description></project>' -H 'Content-type:application/xml' <a class="external" href="http://hostname/projects.xml?key=">http://hostname/projects.xml?key=</a>...............................................</p>
<p>But, still I could not be able to create a new project. Note that I removed -u option from the command. Could you please look into this .</p> Redmine - Defect #6667: REST API call with POST/PUThttps://www.redmine.org/issues/6667?journal_id=229212010-12-02T15:16:30ZTomasz Muszyński
<ul><li><strong>Assignee</strong> set to <i>Jean-Philippe Lang</i></li></ul><p>I've modified one line of code to get this working.</p>
<pre>
url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id], :key => params[:key])
</pre>
<p>was changed in this code fragment in app/controllers/application_controller.rb:</p>
<pre>
def require_login
if !User.current.logged?
# Extract only the basic url parameters on non-GET requests
if request.get?
url = url_for(params)
else
url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id])
end
respond_to do |format|
format.html { redirect_to :controller => "account", :action => "login", :back_url => url }
format.atom { redirect_to :controller => "account", :action => "login", :back_url => url }
format.xml { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
format.js { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
format.json { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
end
return false
end
true
end
</pre>
<p>Unfortunately, i'm not a ruby programmer, so i'm not sure that above change is enough, but it's working for me.</p>
<p>Above solution fixes closed bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Defect: Issues API doesn't allow full key auth for all actions (Closed)" href="https://www.redmine.org/issues/6447">#6447</a> which is still not working properly. Jean, I've assigned it to you as you closed <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Defect: Issues API doesn't allow full key auth for all actions (Closed)" href="https://www.redmine.org/issues/6447">#6447</a> :)</p> Redmine - Defect #6667: REST API call with POST/PUThttps://www.redmine.org/issues/6667?journal_id=268192011-03-23T08:38:17ZToshi MARUYAMA
<ul><li><strong>Category</strong> set to <i>REST API</i></li></ul> Redmine - Defect #6667: REST API call with POST/PUThttps://www.redmine.org/issues/6667?journal_id=362092012-02-21T06:15:10ZRedminePro Yang
<ul></ul><p>Holger Just wrote:</p>
<blockquote>
<p>The REST API does <strong>not</strong> use your username and password via basic auth. Instead, each account has an assigned key (which you can find in the sidebar at <a class="external" href="http://yourredmine.com/my/account">http://yourredmine.com/my/account</a>. That key is used exclusively for authentication, as you have done in your second example. The username and password were ignored completely.</p>
</blockquote>
<p>Why the API Access Key is not showed in <a class="external" href="http://demo.redmine.org/my/account">http://demo.redmine.org/my/account</a> any more?</p>