Comments (3)
Hi
you don't need to pass the "protocol" as an option to the client. If you
want to call a service through https you just have to use that protocol in
the url, and the client will do the rest of the work for you. ie.:
var Client = require('node-rest-client').Client
var client =new Client();
// call "https" site using the way you prefer between the ones client has
// direct way
client.get("https://remote.site/rest/xml/method", function(data, response){
// parsed response body as js object
console.log(data);
// raw response
console.log(response);
});
If you need to add basic auth to each call just pass username and password
as options to the client, as follow:
var Client = require('node-rest-client');
var auth_options ={
user:"admin",
password:"admin_password"
}
var client = new Client(auth_options);
as you can see in documentation "protocol" is not an allowed option for the
client
Options parameters
You can pass the following args when creating a new client:
var options ={
// proxy configuration
proxy:{
host:"proxy.foo.com", // proxy host
port:8080, // proxy port
user:"ellen", // proxy username if required
password:"ripley" // proxy pass if required
},
user:"admin", // basic http auth username if required
password:"123" // basic http auth password if required};
Hope it helps
On Wed, Apr 24, 2013 at 4:13 AM, Cristian Bullokles <
[email protected]> wrote:
I'm trying to call Client using the next code:
Client = require('node-rest-client').Client;
var options = { protocol: "https"};
var client = new Client(options);But I'm receiving the error below:
http.js:1604
throw new Error('Protocol:' + options.protocol + ' not supported.');
^
Error: Protocol:https: not supported.
at Object.exports.request (http.js:1604:11)—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1
.
from node-rest-client.
That was my first test, without any options... in fact my initial code is:
var sys = require('util');
var Client = require('node-rest-client').Client;
var client = new Client();
var args ={
path:{"apikey":""},
parameters:{lat:xx,lon:xx},
headers:{"test-header":"client-api"}
};
client.get("https://api.forecast.io/forecast/${apikey}/${lat},${lon}", args,
function(data, response){
// parsed response body as js object
console.log(data);
// raw response
console.log(response);
});
http.js:1604
throw new Error('Protocol:' + options.protocol + ' not supported.');
^
Error: Protocol:https: not supported.
at Object.exports.request (http.js:1604:11)
at Object.ConnectManager.normal
(C:\Projects\Sensing\research\node_modules\node-rest-client\lib\node-rest-client.js:273:24)
at Object.exports.Client.Util.connect
(C:\Projects\Sensing\research\node_modules\node-rest-client\lib\node-rest-client.js:131:20)
On Thu, Apr 25, 2013 at 5:43 PM, Alejandro Alvarez Acero <
[email protected]> wrote:
Hi
you don't need to pass the "protocol" as an option to the client. If you
want to call a service through https you just have to use that protocol in
the url, and the client will do the rest of the work for you. ie.:var Client = require('node-rest-client').Client
var client =new Client();// call "https" site using the way you prefer between the ones client has
// direct way
client.get("https://remote.site/rest/xml/method", function(data,
response){
// parsed response body as js object
console.log(data);
// raw response
console.log(response);
});If you need to add basic auth to each call just pass username and password
as options to the client, as follow:var Client = require('node-rest-client');
var auth_options ={
user:"admin",
password:"admin_password"}
var client = new Client(auth_options);
as you can see in documentation "protocol" is not an allowed option for
the
clientOptions parameters
You can pass the following args when creating a new client:
var options ={
// proxy configuration
proxy:{
host:"proxy.foo.com", // proxy host
port:8080, // proxy port
user:"ellen", // proxy username if required
password:"ripley" // proxy pass if required
},
user:"admin", // basic http auth username if required
password:"123" // basic http auth password if required};Hope it helps
On Wed, Apr 24, 2013 at 4:13 AM, Cristian Bullokles <
[email protected]> wrote:I'm trying to call Client using the next code:
Client = require('node-rest-client').Client;
var options = { protocol: "https"};
var client = new Client(options);But I'm receiving the error below:
http.js:1604
throw new Error('Protocol:' + options.protocol + ' not supported.');
^
Error: Protocol:https: not supported.
at Object.exports.request (http.js:1604:11)—
Reply to this email directly or view it on GitHub<
https://github.com/aacerox/node-rest-client/issues/1>
.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-17039157
.
from node-rest-client.
Hi
I've been reviewing the code and you were right. There was a problem with options passed to http/https libs in node.js probably due to a new version of those libs.
Anyway, I've fixed the code (and test it with the url of your example) and publish the update to github and npm as version 0.0.3.
hope now it works for you.
from node-rest-client.
Related Issues (20)
- Vulernability in debug-2.2.0
- promise from http calls HOT 2
- TLS 1.2 Support HOT 1
- Support for retry HOT 1
- Cannot get examples to work HOT 2
- Handle JSON Hijacking prevention HOT 1
- xmlSerializer is not defined
- NPM Vulnerability HOT 2
- Problem behind a Proxy with Tunnel HOT 4
- Can I send a binary file with this?
- "node_modules\node-rest-client\lib\nrc-serializer-manager.js:122" HOT 1
- Result is not defined in nrc-parser-manager HOT 1
- Use a loop? HOT 1
- HTTPS: unable to verify the first certificate error HOT 2
- https encryption
- Content-Type header is case sensitive
- Cannot send multipart/form-data
- The git repository has been abandoned
- "Error: socket hang up" when using node-rest-client if follow-redirects Ver > 1.13.3 HOT 1
- Replace xml2js due to CVE-2023-0842
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-rest-client.