0

我继承了 Excel Tracker 工作表,代码最初是由离开公司的其他人创建的。

我们有一个 Excel VBA 跟踪器表,它与 Jira 通信并用于毫无问题地获取项目和问题,直到我们公司从 cookie 的站点管理员更改为更安全的 cookie 的“隔离站点管理员”,因为切换到隔离站点minder cookie 身份验证我们的 Excel 跟踪表将毫无问题地从 Jira 获取项目密钥,但无论我们查询 Jira 的哪个项目,无论我们如何更改代码,它都会带来相同的 50 个问题列表,它不会看到问题“Key " 并过滤并获取项目的正确问题。我不像 Excel VBA 那样出色,但我确实理解并且可以按照代码在做什么并进行小的调整,但是我现在继承了这个跟踪表并且不太擅长 Jira 代码和相互交流

代码如下:

Public Function httpGet (ByVal url as String) As String()
Dim resultArray(2) as String 
Dim PostData as String
url = baseurl + url
Dim smiwhr As New SMIsolatedWinHttpRequest

  With CreateObject("WinHTTP.WinHTTPrequest.5.1")
    .Option(WinRequestOption_EnableRedirects) = True 
    .Option(WinRequestOption_EnableHttpsToHttpRedirects) = True
    smiwhr.NewRequest "GET", url
    smiwhr.Send PostData

    .Open "GET", url, False
    .SetRequestHeader "Content-Type", "Application/json"
    .SetRequestHeader "Accept", "application/json"
    .SetRequestHeader "Cookie", sCookie
    .Send
    resultArray(0) = Status
    resultArray(1) = .ResponseText

  End With
  httpGet = resultArray
End Function  

有一个函数可以获取具有代码的请求:

Public Function getRequestByPaging(ByVal projectKey as String, ByVal StartIndex as Integer, Optional maxResults As Integer, Optional fields As String) As Object
  Dim resultArray() As String
  Dim api as String
  Dim jql As String
  Dim PostData As String
  api = "rest/api/2/search"
  jql = "project=" & projectKey & " and issuetype!=\""Project\"" ORDER By Key ASC "
  PostData = "{"
  PostData = PostData + toJson ("jql", jql) + ","
  PostData = PostData + toJson("StartAt", StartIndex) + ","
  If maxResults <> "" Then
    PostData = PostData + toArray("field", fields) + ","
  End If
  PostData = Mid(PostData, 1, Len(PostData) - 1)
  PostData = Post + "}"
End Function  

jql 部分确实获取了项目密钥,当它将项目的详细信息发送到 Json 时,它返回了错误的问题密钥 

Json函数如下:

Public Function toJson (byVal As String, ByVal value As String) As String
  If value = "" Then
    toJson = """" + key + """ : null"
  Else
    toJson = """" + key + """ : """ + value + """"
  End If
End Function

任何帮助将不胜感激

4

1 回答 1

0

在编辑您的原始问题并为其添加语法突出显示(否则您的代码无法读取)时,我注意到相关函数中的语法可能是错误的:

你有它:

  If value = "" Then
    toJson = """ + key + """ : null"
  '          ^^^ missing "
  Else
    toJson = """" + key + """ : """ + value """"
  '                                         ^ missing +
  End If

应该是这样的:

  If value = "" Then
    toJson = """" + key + """ : null"
  Else
    toJson = """" + key + """ : """ + value + """"
  End If
于 2021-05-13T12:02:21.067 回答