Hello,
I am working on VBA code to create a story via REST API call. I am able to create a story successfully as long as I do not have assignee name in the request. See code below. I don't know where I am going wrong. As long as I remove the "assignee" in the post string, I am able to execute the code. If I did not remove then I am getting 400 response code.
Sub UpdateJIRAStories()
sJIRAInstance = "https://horizon.se.bank.com/issues2"
' sJIRAInstance = "https://jira3.horizon.bank.com"
' Set OutlookApp = New Outlook.Application
' Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
' Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox).Folders("Test") ---- , ""assignee"":{""name"":""" & sAssigneeName & """}
i = 3
lRow = Worksheets("Create JIRA Issues").Cells(Rows.Count, 1).End(xlUp).Row
While i <= lRow
sProject = "SISBTXTRPR"
sSummary = Worksheets("Create JIRA Issues").Cells(i, "A")
sDescription = Worksheets("Create JIRA Issues").Cells(i, "B")
sIssueType = "Story"
sAssigneeName = Worksheets("Create JIRA Issues").Cells(i, "G")
sURL = sJIRAInstance & "/rest/api/latest/issue"
sData = " { ""fields"" : { ""project"" : { ""key"" : """ & sProject & """ }, ""summary"" : """ & sSummary & """, ""description"" : """ & sDescription & """, ""assignee"" : { ""name"" : """ & sAssigneeName & """ }, ""issuetype"" : { ""name"" : """ & sIssueType & """ } } } "
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
Hi @Balaji ,
The format of the assignee json snippet must be as below.
"assignee": { "id": "5b109f2e9729b51b54dc274d" }
Here "5b109f2e9729b51b54dc274d" is the account id of the assignee. You can get account id of a user using User Rest API.
That's correct. I have realized this after posting the question. Thank you nevertheless. On a different note, I'd hate to hot-link an unrelated question but could you take a look at this as well?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.