При создании новой проблемы JIRA с использованием REST API в VBA я получаю следующее сообщение об ошибке для настраиваемого поля 13744: «Значение операции должно быть числом».
Я протестировал следующий код без числового поля, и все работает нормально, проблема создана, и переданы все остальные значения полей:
Public Pass As Variant
Sub criarIssue()
Dim JiraService As New MSXML2.XMLHTTP60
Dim sErg As Variant
Dim sRestAntwort As Variant
Dim sSummary As Variant
Dim sDescription As Variant
Dim sProject As Variant
Dim sIssueType As Variant
Dim sData As Variant
Dim sPath As Variant
Dim sUsername As Variant
Dim sPassword As Variant
Dim sAux As Variant
Dim sStatus As Variant
Dim sEncbase64Auth As Variant
sUsername = Environ$("UserName")
Senha.Show
sPassword = Pass
sSummary = ActiveSheet.Range("C3").Value 'Issue name
sIssueType = "Projeto"
sProject = "EXP"
sData = " { ""fields"" : { ""project"" : { ""key"" : """ & sProject & """ }, ""summary"" : """ & _
sSummary & """, ""issuetype"" : { ""name"" : """ & sIssueType & """}, ""customfield_13744"" : ""1234"", ""customfield_13663"" : {""name"" : ""vitor.ribeiro""}, ""customfield_13670"" : ""2019-01-23 00:00:00"", ""customfield_13671"" : {""value"" : ""SP"" , ""child"" : {""value"" : ""SAO PAULO"" }}}} "
sEncbase64Auth = EncodeBase64(sUsername & ":" & sPassword)
'Creates Issue
With JiraService
.Open "POST", "http://172.16.2.128:8080/rest/api/2/issue/", False
.SetRequestHeader "Content-Type", "application/json"
.SetRequestHeader "Accept", "application/json"
.SetRequestHeader "X-Atlassian-Token", "nocheck"
.SetRequestHeader "Authorization", "Basic " & sEncbase64Auth
.Send (sData)
sRestAntwort = .ResponseText
sStatus = .Status & " | " & .StatusText
End With
' JSON Response
sAux = Replace(sRestAntwort, "{", "")
sAux = Replace(sAux, "}", "")
sAux = Split(sAux, ",")
sAux = sAux(1)
sAux = Split(sAux, ":")
sAux = sAux(1)
sAux = Replace(sAux, """", "")
ActiveSheet.Range("J2").Value = sStatus
ActiveSheet.Range("J3").Value = sRestAntwort & " | " & sAux
ActiveSheet.Range("J4").Value = ActiveSheet.Range("J4").Value + 1
ActiveSheet.Range("C2").Value = sAux
With JiraService
.Open "DELETE", "http://172.16.2.128:8080/rest/auth/1/session", False
.Send
End With
End Sub
Public Function EncodeBase64(text As String) As String
Dim arrData() As Byte
arrData = StrConv(text, vbFromUnicode)
Dim objXML As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMElement
Set objXML = New MSXML2.DOMDocument
Set objNode = objXML.createElement("b64")
objNode.DataType = "bin.base64"
objNode.nodeTypedValue = arrData
EncodeBase64 = objNode.text
Set objNode = Nothing
Set objXML = Nothing
End Function
Все значения, кроме настраиваемого поля 13744, передаются без проблем.
Для этого я получаю следующее сообщение об ошибке:
{"errorMessages": [], "errors": {"customfield_13744": "Значение операции должно быть числом"}
Почему он не распознается как число?