Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Using REST API to edit issue - CURL succeeds, programmatically fails

I'm trying to use the Jira REST API to update issues programmatically via a MacOS program, written in Swift. I have a Jira API Token and have succeeded using CURL. Here is the command: 

curl --request PUT \
  --url '' \
  --user '' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
"update": {
"timetracking": [
"edit": {
"originalEstimate": "1w 1d"

Where zzz is the API Token. This works and the field is updated correctly. 

The code version mirrors this as closely as I can, but fails with the error 

Response: {"errorMessages":["Issue does not exist or you do not have permission to see it."],"errors":{}}

Here is the Swift code: 

        let tokenString = ""

        guard let encodedTokenString = .utf8)?.base64EncodedData() else { fatalError("Can't encode token") }

        let authString = String("Token token=\(encodedTokenString)")

        guard let url = URL(string: "")

        else {
            fatalError("Couldn't create a static URL")

        let request = NSMutableURLRequest(url: url)

        request.addValue(authString, forHTTPHeaderField: "Authorization")

        request.addValue("application/json", forHTTPHeaderField: "Content-Type")

        request.httpMethod = "PUT"

        let dataString = "{\"update\": {\"timetracking\": [{\"edit\": {\"originalEstimate\": \"1w 1d\"}}]}}".utf8

        let body = Data(dataString)    

        request.httpBody = body

        let session = URLSession.shared

        session.dataTask(with: request as URLRequest) { (data, response, error) -> Void in

            guard let data = data, let responseString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as String?, !responseString.isEmpty else {
                print("No valid response!")
            print("Response: " + responseString)


What am I missing? 

1 answer

1 accepted

0 votes
Answer accepted
DPK J Community Leader Sep 17, 2020

@Janene Pappas I'm not a Swift expert but your 'authString' have some issues.

let authString = String("Token token=\(encodedTokenString)")

This should be (in my opinion)

let authString = String("Basic \(encodedTokenString)")

ahhhh thank you!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

JSM June ask me anything (AMA)

Hello Community members! We’re wrapping up the end of JSM June with an Ask Me Anything (AMA) with the Jira Service Management product team. This is your chance to ask all your ITSM questions to o...

93 views 4 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you