Let's imagine I have a specific URL
https://exampleAPI.com/authorize?param1=value1¶m2=value2
Where param1 and param2 are the payload values being sent. How can I execute a POST request in this particular way?
I attempted the following:
var https = require('https')
var options = {
url: 'https://exampleAPI.com/authorize?param1=value1¶m2=value2',
method: 'POST',
headers: {
....
}
}
https.request(options, function(res) {
var str = ""
res.on('data', function(data){
str+=data
})
res.on('end', function() {
console.log(str)
})
})
I'm not receiving any data back. What could I be doing incorrectly?
Edit: Here is the structure I believe is correct:
REQUEST
POST https://exampleAPI.com/us/oauth/v2/authorize?response_type=code&client_id=exampleId&redirect_uri=exampleSite.com HTTP/1.1
Accept: application/json, application/xml, text/json, text/x-json, text/javascript, text/xml
User-Agent: RestSharp/105.2.3.0
Content-Type: application/x-www-form-urlencoded
Host: exampleAPI.com
Content-Length: 98
Accept-Encoding: gzip, deflate
username=someuser&password=somepassword&action=Log%20In&sessionID=someSessionId