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
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
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.