Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Receiving projects list using JIRA API

Олег Корчицкий August 5, 2015

I want make simple JIRA assistant for iOS but cannot figure out why API call return empty array.

For example, using this code i'm trying to get projects list:

let request = NSMutableURLRequest(URL: "http://myjira.atlassian.net/rest/api/2/project".URL!)
	request.addValue("Basic " + emailAndPasswordAsb64String, forHTTPHeaderField: "Authorization")
	request.addValue("application/json", forHTTPHeaderField: "Content-Type")
	request.HTTPMethod = "GET"

let session = NSURLSession.sharedSession()

session.dataTaskWithRequest(request) { (data, response, error) -> Void in
	guard let data = data, responseString = NSString(data: data, encoding: NSUTF8StringEncoding) as? String where !responseString.isEmpty else {
		print("No valid response!", appendNewline: true)
		return
	}

	print("Response: " + responseString, appendNewline: true)

}.resume()

But getting this:

`Response: []`

I'm also tried to use some other API, for example `api/2/dashboard`, but received this:

`Response: {"startAt":0,"maxResults":20,"total":0,"dashboards":[]}`

Using `api/2/myself` i received this:

`Response: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>401</status-code><message>Client must be authenticated to access this resource.</message></status>`

Maybe i missed something and project can be invisible? But for basic authorization i'm using administrator login and password.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Олег Корчицкий August 6, 2015

Finally figured it out!

I did two mistakes:

1. http is wrong, https is right!
2. emailAndPasswordAsb64String was created using email and password, it's wrong! User should type in username instead of email! For administrator account username is admin by default.

Hope this will help someone!

TAGS
AUG Leaders

Atlassian Community Events