Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Balu All December 26, 2019

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
Atlassian Team members are employees working across the company in a wide variety of roles.
January 3, 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
AUG Leaders

Atlassian Community Events