How do I POST to external url in Parse.com from the cloud?
I looked around but there seems to be nothing in Parse.com's forums, and the generic javascript solution involves creating a form object:
var form = document.createElement("form");
which is obviously not the solution I need because I need to submit the url from the server (cloud code.)
What I'm looking for is something like this:
var url = "http://servername/v1/submit?";
var params = "lm_form=33333&lm_key=55555&fld_28226=name"
url = url + params;
var response = submitToUrl(url);
So the question is, what does submitToUrl look like?
EDIT: following Wain's answer I'm using this:
Parse.Cloud.httpRequest({
url: url,
method: 'POST',
success: function(resp) {
console.log("request submited " + resp);
},
error: function(httpResponse) {
console.log('Request failed with response code ' + httpResponse.status);
}
});
with the url being the url + params from above. It triggers the success method but with 400 error code.
Submitting the same url through the browser window works fine. What am I missing?