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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Unable to set Original Estimate on a task using VBA/REST - Error code 400 Edited

Hello, 

 

I am trying to log work estimates via a REST API call using VBA. Here is my code. It is returning a code 400.  

 

Sub UpdateJIRAWorkLogs()

i = 3

sResponse = MsgBox("Click OK to begin writing to JIRA", vbOKCancel)

If sResponse = vbCancel Then
Exit Sub
End If

lRow = Worksheets("Bulk Update Worklogs").Cells(Rows.Count, 1).End(xlUp).Row

While i <= lRow
sProject = "SISBTXTRPR" 
sIssueType = "Sub-task"

sURL = "https://MyCompany.com/issues2/rest/api/latest/issue/SISBTXTRPR-383/worklog"


 sData = "{""newEstimate"": 36000}"


With JiraService
DoEvents
.Open "POST", sURL, False
.SetRequestHeader "Content-Type", "application/json"
.SetRequestHeader "Accept", "application/json"
.SetRequestHeader "Authorization", "Basic " & UserPassBase64
.SetRequestHeader "X-Atlassian-Token", "nocheck"
.Send (sData)

If .Status = "401" Then
MsgBox "Not authorized or invalid username/password"
Else
End If
End With

i = i + 1

Wend

MsgBox "Insert Complete", vbInformation

End Sub

 

1 answer

0 votes
Andy Heinzer Atlassian Team Jan 03, 2020

Hi Balu,

I see that you are trying to make a REST API call to a Jira Cloud site.  However given the response you are seeing here, it certainly looks like your request is not authenticating as you expect here.

Instead of using the account password to do the authentication, I would recommend that you generated an API token.  You can then build a new base64 encoded string in the format of:

user@example.com:API_Token

and then pass that string in an authorization header of the call.  More details on the steps needed to encode that string can be found in Basic auth for REST APIs.

It is quite possible that you were able to use the password instead for REST API calls to Jira Cloud. However Atlassian changed this behavior about 6 months ago. This change goes back to our Deprecation notice - Basic authentication with passwords and cookie-based authentication

In short, you can't use passwords for REST API calls to Jira Cloud sites anymore.  But you should still be able to create a token to complete basic authentication, you just need to follow the steps in that guide to make sure that you have encoded it in the correct format.

Try that first.  And let me know if that helps.

Andy

Suggest an answer

Log in or Sign up to answer
TAGS

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