These are chat archives for request/request

2nd
Jul 2015
patthehat033
@patthehat033
Jul 02 2015 07:13
Hey is anyone online I have some questions about request.
patthehat033
@patthehat033
Jul 02 2015 07:26
This message was deleted
I am new to server requests and am having some issues. So I managed to get my POST request to work from the curl command line. All that was required was my username and password on the command line sent as post data. Then it returned a response with my account information. Now I am trying to do the same thing but with Javascript not the command line. I am trying to authenticate for Vine's API. Here is my code
var options = {
    method: 'POST',
    url: 'https://api.vineapp.com/users/authenticate',
    json: 'true',
    body: 'form',
    postData: {
       'auth': {
            'username': 'xxxx',
            'password': 'xxxx',
            'sendImmediately': false
      }
    }
};

var request = require('request');
request(options, function (error, response, body) {
  if (!error && response.statusCode == 200) {
     console.log(body)
  }
    else
    {
        console.log(response.statusCode);
    }
})
Mr-KoKa
@Mr-KoKa
Jul 02 2015 08:27
@patthehat033 try to remove body: 'form', line from your options, it is for data too, like postData and form, it doesn't specify body type or anything like that, and if it still won't work, try to pass your data in form option instead of postData one. Also you may want to use true as bool, not as string when setting up options such as json.
patthehat033
@patthehat033
Jul 02 2015 08:34
Mr-KoKa, your advice worked awesome!! The post data needed to be changed to form. I am still developing this program, I will have more questions... talk to you soon. :)