2017-10-20 26 views
2

以下のCURLリクエストから古典的なASPコードを作成するのを手伝ってもらえますか?古典ASPのCURLリクエスト

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.

+0

[Documentation](https://manual.seafile.com/develop/web_api.html#shared-libraries)を参考にしてください。 – Lankymart

+0

[私のコードのように見える](https://stackoverflow.com/a/37462944/692942)。正しいContent-Typeを渡したり、いくつかの要件がないためにエラーが発生している可能性があります。 – Lankymart

答えて

1

問題はコードではありません、私はここにバージョン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認証ヘッダーに使用されている一重引用符が好きではないと思われました。関係なく、あなたがAPIを呼び出すために使用するものの方法の起こるか

schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The target principal name is incorrect.

>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. 

ここでの問題は、エラーです。ブラウザのアドレス

https://cloud.seafile.com/api2/beshared-repos/ 

をチェック

は、サイトがGoogle Chromeで確保し、名前がSSL証明書に一致していない表示されますSSL checkerを使用していないことを警告につながります。

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 .

+0

フィードバックのための@Lankymartありがとうございました、問題はSSL証明書にあった! – RAJ

関連する問題