Jignesh Patel
Jignesh Patel

Reputation: 199

POST CURL with request header and payload in vbscript

I have created a project on parse.com with cloud code.

Now I want to create a VBScript to call CURL as below.

curl -X POST \
  -H "X-Parse-Application-Id: myAppId" \
  -H "Content-Type: application/json" \
  -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
  http://localhost:1337/parse/classes/GameScore

curl -X POST \
  -H "X-Parse-Application-Id: myAppId" \
  -H "Content-Type: application/json" \
  -d '{}' \
  http://localhost:1337/parse/functions/hello

In javascript we can achieve it by following code.

Parse.initialize('myAppId','unused');
Parse.serverURL = 'https://whatever.herokuapp.com';

var obj = new Parse.Object('GameScore');
obj.set('score',1337);
obj.save().then(function(obj) {
  console.log(obj.toJSON());
  var query = new Parse.Query('GameScore');
  query.get(obj.id).then(function(objAgain) {
    console.log(objAgain.toJSON());
  }, function(err) {console.log(err); });
}, function(err) { console.log(err); });

How can I achieve it using VBScript for .vbs file?

Upvotes: 0

Views: 7271

Answers (1)

Salman Kaludi
Salman Kaludi

Reputation: 29

Please try the following code.

strRequest="{""eventId"":""TOaDAOqueV""}"
EndPointLink = "http://X.X.X.X:1337/parse/functions/method"

dim http
set http=createObject("Microsoft.XMLHTTP")
http.open "POST",EndPointLink,false
http.setRequestHeader "Content-Type","application/json"
http.setRequestHeader "X-Parse-Application-Id","XXXXXXXXXXXXXXXXXXXXX"

msgbox "REQUEST : " & strRequest
http.send strRequest

If http.Status = 200 Then
    msgbox "RESPONSE : " & http.responseText
    responseText=http.responseText
else
    msgbox "ERRCODE : " & http.status
End If

Answer partially taken from HTTP GET in VBS by @rajkumar-joshua-m

Upvotes: 2

Related Questions