I'm looking for a spot of basic tech help with Cloudscript calling a 3rd party web hook please. I'm following the example given here: https://api.playfab.com/docs/tutorials/landing-automation/making-webhook-calls-from-cloud-script
The Cloudscript http.request is a Playfab implementation, with no documentation other than the page above that I can find, so as a game but non-web developer I'm having trouble translating from demo code that uses built in node.js http.request, as the 2 don't work the same.
It partially works. I can get a response from the web server but I can't work out how to package up the auth part and the param part in the code below. How do I put them in the header and/or body please?
Thanks in advance for the help.
// Cloud Script example from: https://api.playfab.com/docs/tutorials/landing-automation/making-webhook-calls-from-cloud-script var url = "http://demo.3rdparty.com"; // <- got this piece working fine var method = "post"; var contentBody = ""; var contentType = "application/json"; var headers = {}; var responseString = http.request(url, method, contentBody, contentType, headers); // 3rd party demo code, uses node.js http.request var http = require('http'); // Build the request parameters first var options = { protocol: "http:", hostname: "demo.3rdparty.com", method: "POST", headers: { "Content-Type": "application/json" }, auth: "myKeyHere" // <- how do I get this piece into the Cloudscipt one? }; // Make the request var request = http.request(options, function (response) { // Prepare to store the response body var chunks = []; // Collect the data from the response response.on('data', function (data) { chunks.push(data); }); // Once we have all the data, assemble it all and output it. response.on('end', function () { console.log('Response data: ' + chunks.join().toString()); }); }); // Write the data to the request stream request.write("{ \"param\": \"Test string\" }"); // <- and this piece? // Execute the request request.end();