Authenticating to On Demand Jira using using remote api

suhaim abdussamad May 16, 2013

Hi

I am trying to follow this documentation - https://confluence.atlassian.com/display/JIRA043/JIRA+REST+API+(Alpha)+Tutorial I am at this step -

curl -c cookie_jar -H "Content-Type: application/json" -d '{"username" : "admin", "password" : "admin"}' http://localhost:8090/jira/rest/auth/latest/session

When I do this with my on demand instance, where I replace localhost:8090 with our on demand url, and the username and password with my own. I get this

<html>

<head><title>301 Moved Permanently</title></head>

<body bgcolor="white">

<center><h1>301 Moved Permanently</h1></center>

<hr><center>nginx</center>

</body>

</html>

What am I doing wrong?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Marlon Aguiar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 16, 2013

You're welcome! Could you try something like this:

curl -D- -u username:password -H "Content-Type: application/json" 'https://company.atlassian.net/rest/api/latest/issue/issue-#'

I've tested it here and it works as expected.

Marlon

suhaim abdussamad May 16, 2013

Yes! It worked!

0 votes
Marlon Aguiar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 16, 2013

Could you try example.atlassian.net/rest/api/2/issue/ ? The URL for the API on the latest OnDemand version is a little different than version 4.3.

Just for reference, the full documentation for the latest REST API can be found on this link: https://developer.atlassian.com/static/rest/jira/5.2.11.html

This document also has examples of the latest REST API: https://developer.atlassian.com/display/JIRADEV/JIRA+REST+APIs

Hope this information helps!

Regards,
Marlon

suhaim abdussamad May 16, 2013

Unfortunately, I am getting the same error. Should I set something on the JIRA admin side to make this work?

I just tried https://url/rest/api/latest/issue/PROJ-100 and got this error

&lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 405 - Method Not Allowed&lt;/h1&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;p&gt;&lt;b&gt;type&lt;/b&gt; Status report&lt;/p&gt;&lt;p&gt;&lt;b&gt;message&lt;/b&gt; &lt;u&gt;Method Not Allowed&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;The specified HTTP method is not allowed for the requested resource (Method Not Allowed).&lt;/u&gt;&lt;/p&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;h3&gt;Apache Tomcat/6.0.32&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;%

Marlon Aguiar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 16, 2013

What is the full curl line you are using? It could also be that Remote API Calls are disabled in your instance, to check that go to example.atlassian.net/secure/admin/EditApplicationProperties!default.jspa and check for Accept remote API calls under Options.

Let me know how it goes.

Marlon

suhaim abdussamad May 16, 2013

Accept remote API calls is on. The full curl line is this -

curl -c cookie_jar -H "Content-Type: application/json" -d '{"username" ":"username", "password" :"password"}' "https://company.atlassian.net/rest/api/latest/issue/CYEY-1240"

Full error is below -

&lt;html&gt;&lt;head&gt;&lt;title&gt;Apache Tomcat/6.0.32 - Error report&lt;/title&gt;&lt;style&gt;&lt;!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--&gt;&lt;/style&gt; &lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 405 - Method Not Allowed&lt;/h1&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;p&gt;&lt;b&gt;type&lt;/b&gt; Status report&lt;/p&gt;&lt;p&gt;&lt;b&gt;message&lt;/b&gt; &lt;u&gt;Method Not Allowed&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;The specified HTTP method is not allowed for the requested resource (Method Not Allowed).&lt;/u&gt;&lt;/p&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;h3&gt;Apache Tomcat/6.0.32&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;%

p.s - Thanks for the help!

TAGS
AUG Leaders

Atlassian Community Events