VBScriptでcURLを行うには、WinHttp.WinHttpRequestオブジェクトを使用します。
GET
curl_get.vbs
Dim http: Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
Dim petId: petId = 1
Dim url: url = "https://petstore.swagger.io/v2/pet/" & petId
With http
.Open "GET", url, False
.Send
Wscript.Echo .Status & " " & .StatusText
Wscript.Echo .ResponseText
End With
>cscript /nologo curl_get.vbs
200 OK
{"id":1,"category":{"id":0,"name":"DOGS"},"name":"doggie","photoUrls":["string"],"tags":[{"id":0,"name":"string"}],"status":"available"}
POST
curl_post.vbs
Dim http: Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
Dim url: url = "https://petstore.swagger.io/v2/store/order"
Dim data: data = "{ ""id"": 1, ""petId"": 1, ""quantity"": 0, ""shipDate"": ""2019-08-24T04:07:54.083Z"", ""status"": ""placed"", ""complete"": false}"
With http
.Open "POST", url, False
.SetRequestHeader "Content-Type", "application/json"
.Send data
Wscript.Echo .Status & " " & .StatusText
Wscript.Echo .ResponseText
End With
>cscript /nologo curl_post.vbs
200 OK
{"id":1,"petId":1,"quantity":0,"shipDate":"2019-08-24T04:07:54.083+0000","status":"placed","complete":false}
WinHttpRequestオブジェクトの詳細なリファレンスはコチラ