Call a web service

143 views
Skip to first unread message

Nikos Galanakis

unread,
Sep 4, 2014, 9:49:07 AM9/4/14
to nod...@googlegroups.com
Hi , i just started to play with node i am trying to build a app.In a module i am trying to call a web service which has a API KEY.
Here is my code:
var request = require('request');
request('URL', function(error, response, body){
if(!error && response.statusCode == 200){
    console.log(body)
}
    else{
        console.log(response.statusCode);
    }
})
            The answer is 401(not authorized!!!)

Where have to put the Api key into my code to get the data from the service?
Thanks

Ryan Schmidt

unread,
Sep 4, 2014, 1:31:48 PM9/4/14
to nod...@googlegroups.com
Each web service is different; you would have to consult that service's documentation.


Aria Stewart

unread,
Sep 4, 2014, 1:34:36 PM9/4/14
to nod...@googlegroups.com
that depends on where in the response your service expects the API key.

What service is this? What authentication system (custom to the service?)

Aria

Nikos Galanakis

unread,
Sep 4, 2014, 3:57:07 PM9/4/14
to nod...@googlegroups.com
t's a typical REST service of prestashop (eshop platform).The only paradigms which have seen are using a PHP library of prestashop.

greelgorke

unread,
Sep 5, 2014, 4:18:27 AM9/5/14
to nod...@googlegroups.com
Please read the documentation of the request module. there are even examples of how to use webservices with authorisation and api keys. Hint: https://github.com/mikeal/request#http-authentication and following
Reply all
Reply to author
Forward
0 new messages