2017-10-20 8 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/ 

확인

사이트가 구글 크롬에서 확보하고 이름이 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