我们有一个用.NET(4.6.1)编写的安静的Web应用程序,它有以下UriTemplate:
[OperationContract]
[WebGet(UriTemplate = "/GetAssociationLevelCustomerData/{environment}/{AssetKeyFilter=-1}/{UsersTZOffset=0}",
ResponseFormat = WebMessageFormat.Json)]
public PLEGatewayCore.Entities.M2MDB.DSPAssociationItem GetAssociationLevelCustomerItem(string environment, String AssetKeyFilter, string UsersTZOffset)
然后我们有一个经典的ASP(3.0)(VbScript)应用程序试图通过以下机制从中获取数据:
Sub ExecuteWebRequest(strMethod, url, data, intStatus, strResponse)
Dim webRequest
'On Error Resume Next
Set webRequest = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
If Err.Number <> 0 Then
intStatus = -1
strResponse = "(" & Err.Number & ") " & Err.Description
Else
With webRequest
.Open strMethod, url, false
.SetRequestHeader "Content-Type", "application/json"
.SetRequestHeader "Authorization", Session("ses_APIToken")
.SetRequestHeader "Ver", "3.0"
.SetRequestHeader "SourceId", "3"
IF strMethod = "POST" THEN
.Send data
ELSE
.Send
END IF
If Err.Number <> 0 Then
intStatus = -1
strResponse = "(" & Err.Number & ") " & Err.Description
Else
intStatus = .Status
strResponse = "(" & .Status & ") " & .StatusText
If .Status = "200" Then strResponse = .ResponseText End If
End if
End With
End If
Set webRequest = Nothing
'Exit Sub
End Sub
示例:
https://<url>/GetAssociationLevelCustomerData/PROD/6108213631162262528/4
作品
https://<url>/GetAssociationLevelCustomerData/PROD/6108213631162262528
不起作用
我们注意到的是,如果我们不使用像#34; UsersTZOffset&#34;这样的可选/默认参数,那么请求将失败。如果我们从PostMan运行网址,我们就没有问题。什么可能导致这种行为?它是与XMLHttp.6.0对象有关,还是在restful api端点中的某些东西,还是完全不同的东西?