我试图通过单击按钮从VBA调用Salesforce市场营销云(我可以使用soap UI轻松调用)基于休息的Web服务
但是我没有得到预期的回复。我无法在Salesforce端进行调试,因为我无法访问营销云服务器
Private Sub cmd_connect_Click()
Dim clientSecret As String
Dim clientId As String
Dim TenentId As String
Dim objRequest As Object
Dim strUrl As String
Dim blnAsync As Boolean
Dim strResponse As String
Dim ReqBody As String
clientId = Worksheets("01Configure").txt_clientId.Value
clientSecret = Worksheets("01Configure").txt_clientSecret.Value
TenentId = Worksheets("01Configure").txt_TenentId.Value
strUrl = "https://" + TenentId + ".auth.marketingcloudapis.com" + "/v1/requestToken"
ReqBody = "{" & Chr(34) & "clientId" & Chr(34) & ":" & Chr(34) & "" + clientId + "" & Chr(34) & "," & Chr(34) & "clientSecret" & Chr(34) & ":" & Chr(34) & "" + clientSecret + "" & Chr(34) & "}"
MsgBox ReqBody
Set objRequest = CreateObject("MSXML2.XMLHTTP")
MsgBox strUrl
blnAsync = True
With objRequest
.Open "POST", strUrl, blnAsync
.SetRequestHeader "Content-Type", "application/json"
.Send ReqBody
'spin wheels whilst waiting for response
While objRequest.readyState <> 4
DoEvents
Wend
strResponse = .ResponseText
End With
MsgBox strResponse
End Sub
我希望得到这样的答复:
{
"accessToken": "Zp0JAhnyvWBBsS23e79Yp0CB",
"expiresIn": 3479
}