经典中的 CURL 请求 ASP
CURL request in classic ASP
有人可以帮我根据下面的 CURL 请求创建经典 asp 代码吗?
curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/beshared-repos/"
我尝试了下面的示例代码,但没有成功。
Dim http: Set http = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
Dim url: url = "https://cloud.seafile.com/api2/beshared-repos/"
Dim data: data = "token=f2210dacd9c6ccb8133606d94ff8e61d99b477fd"
With http
Call .Open("GET", url, False)
Call .SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
Call .SetRequestHeader("Authorization", "Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd")
Call .Send()
End With
If Left(http.Status, 1) = 2 Then
'Request succeeded with a HTTP 2xx response, do something...
Else
'Output error
Call Response.Write("Server returned: " & http.Status & " " & http.StatusText)
End If
它在第 Call.Send()
行抛出以下错误消息
WinHttp.WinHttpRequest error '80090326'
The message received was unexpected or badly formatted.
问题不在于代码,我刚刚用 7.56.0 版测试了您的 curl
调用,结果如下;
首先我尝试了你问题中的命令,但失败了;
>curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/beshared-repos/"
curl: (6) Could not resolve host: Token
curl: (6) Could not resolve host: f2210dacd9c6ccb8133606d94ff8e61d99b477fd'
curl: (35) schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The target principal name is incorrect.
我猜它不喜欢用于 HTTP 授权的单引号 header 所以替换了它们并得到了这个;
>curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" "https://cloud.seafile.com/api2/beshared-repos/"
curl: (35) schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The target principal name is incorrect.
这里的问题是错误:
schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The target principal name is incorrect.
无论您使用何种方法调用 API。
检查地址
https://cloud.seafile.com/api2/beshared-repos/
在浏览器中会导致警告该站点在 Google Chrome 中不安全,并且使用 SSL checker 似乎名称与 SSL 证书不匹配。
None of the common names in the certificate match the name that was entered (cloud.seafile.com). You may receive an error when accessing this site in a web browser. Learn more about name mismatch errors.
有人可以帮我根据下面的 CURL 请求创建经典 asp 代码吗?
curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/beshared-repos/"
我尝试了下面的示例代码,但没有成功。
Dim http: Set http = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
Dim url: url = "https://cloud.seafile.com/api2/beshared-repos/"
Dim data: data = "token=f2210dacd9c6ccb8133606d94ff8e61d99b477fd"
With http
Call .Open("GET", url, False)
Call .SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
Call .SetRequestHeader("Authorization", "Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd")
Call .Send()
End With
If Left(http.Status, 1) = 2 Then
'Request succeeded with a HTTP 2xx response, do something...
Else
'Output error
Call Response.Write("Server returned: " & http.Status & " " & http.StatusText)
End If
它在第 Call.Send()
行抛出以下错误消息WinHttp.WinHttpRequest error '80090326'
The message received was unexpected or badly formatted.
问题不在于代码,我刚刚用 7.56.0 版测试了您的 curl
调用,结果如下;
首先我尝试了你问题中的命令,但失败了;
>curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/beshared-repos/"
curl: (6) Could not resolve host: Token
curl: (6) Could not resolve host: f2210dacd9c6ccb8133606d94ff8e61d99b477fd'
curl: (35) schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The target principal name is incorrect.
我猜它不喜欢用于 HTTP 授权的单引号 header 所以替换了它们并得到了这个;
>curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" "https://cloud.seafile.com/api2/beshared-repos/"
curl: (35) schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The target principal name is incorrect.
这里的问题是错误:
schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The target principal name is incorrect.
无论您使用何种方法调用 API。
检查地址
https://cloud.seafile.com/api2/beshared-repos/
在浏览器中会导致警告该站点在 Google Chrome 中不安全,并且使用 SSL checker 似乎名称与 SSL 证书不匹配。
None of the common names in the certificate match the name that was entered (cloud.seafile.com). You may receive an error when accessing this site in a web browser. Learn more about name mismatch errors.