I'm trying to run a request to an API using NodeJS and the request library.
var creds = {
json: {
email : "user",
pass : "pw"
}
}
var urlPost = "https://api.domain.rocks/auth.php"
request({
url : urlPost,
method : 'POST',
json : true,
body : creds
},
function(error, response, body) {
console.log(response.body)
}
)
I get an error indicating that the parameters in the paramter in the creds json object isn't sent correctl ("bad email"). I've tried all weird combinations of url encoding, query string package ...
I tested in Python, a language I'm more familiar with, and it works there using Python 2.7 and the request library. This gives me the authentication token which is what I need.
payload = {"email" : "email", "pass" : "pw"}
r = requests.post('https://api.domain.rocks/auth.php', data=payload)
rparsed = json.loads(r.text)
Thanks in advance
via Even Even
No comments:
Post a Comment