我尝试编写一个简单的应用程序,该应用程序使用XMLHTTP60创建JIRA票证。 参考本教程:https://www.codeproject.com/Tips/825377/Creating-a-Issue-in-Jira-using-Rest-Api
但是我不知道为什么我总是会得到答复401未经授权。
这是我的代码
Sub Create_JIRA_Ticket()
Dim JiraService As XMLHTTP60 = New XMLHTTP60()
Dim JiraUrl = "https://rb-tracker.bosch.com/tracker/rest/api/2/issue/"
JiraService.open("POST", JiraUrl, False)
JiraService.setRequestHeader("Content-Type", "application/json")
JiraService.setRequestHeader("Accept", "application/json")
JiraService.setRequestHeader("Authorization", "Basic " + GetEncodedCredentials())
Dim JiraJson = "{'fields': {'project':{ 'key': 'BIDOS'},'summary': 'Test_Tool'}}"
JiraService.send(JiraJson)
Dim response As String
Dim status As String
Dim statuscode As Integer
response = JiraService.responseText //Unauthorized-401 pla pla pla...
status = JiraService.statusText //Unauthorized
statuscode = JiraService.status //401
End Sub
Private Function GetEncodedCredentials() As String
Dim mergedCredentials As String = String.Format("{0}:{1}", "GSA81HC", "helloworld")
Dim byteCredentials() As Byte = UTF8Encoding.UTF8.GetBytes(mergedCredentials)
Return Convert.ToBase64String(byteCredentials)
End Function
代码非常简单,我不知道问题出在哪里