Хочу отправить запрос в API (полоса). Я хочу конвертировать curl в winhttp запрос ... Я не могу найти инструкции для этого. это то, что я пытаюсь, но я получаю сообщение об ошибке
Public Sub SendThePostExample()
Dim BaseUrl As String
Dim JBody As String
Dim HReq As New WinHttp.WinHttpRequest
Dim HRes As String
JBody = "{""description"" : ""testing""}"
BaseUrl = "https://api.stripe.com/v1/customers"
HReq.Open "POST", BaseUrl, True
HReq.SetRequestHeader "Content-Type", "application/json"
HReq.SetRequestHeader "Authorization", "Bearer " & "APISecretKey"
HReq.Send (JBody)
HReq.WaitForResponse
HRes = HReq.ResponseText
Debug.Print HRes
MsgBox HRes
Set HReq = Nothing
End Sub
этот код curl, который я хочу преобразовать в httpReq:
curl https://api.stripe.com/v1/customers \
-u API Secret Key: \
-d description="Customer for jenny.rosen@example.com" \
-d source=tok_visa
ошибка, которую я получил:
{
"error": {
"message": "Invalid request (check that your POST content type is application/x-www-form-urlencoded). If you have any questions, we can help at https://support.stripe.com/.",
"type": "invalid_request_error"
}
}