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.
Community moderators have prevented the ability to post new answers.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.