Calling rest api from meteor app

Hi there, how can i call a rest api with authentication from meteor, appreciate if you can guide to an example, i have added the http package to the meteor project. using advanced rest client chrome app, i am able to get the data by passing the following URL and 2 headers. this app is using the already logged in browser session.

URL: https://xxxxx:9443/ccm/oslc/contexts/_ZoC0QNS3EeGPlow7Bl9IAw/workitems
headers: Accept", “application/json"
OSLC-Core-Version”, “2.0”

How can i pass the headers and user name password of the rest api service.

No guarantee, but you could try it like this:

var response = HTTP.get(‘http://blahblah’, {
params: {username: ‘yourvalue’, password: ‘yourvalue’}

this is not working. thanks

Calling rest api is very simple in meteor, more info"GET", "", {
    headers: {
    	"Accept": "application/json",
    	"OSLC-Core-Version": "2.0",

thanks @mrphu3074, tried this, but getting the following error, as we are not passing the username/password, does that mean its using the browser session? Any idea?


why apis use browser session?

if that is possible then i can make meteor app use the already logged in browser session and get the required data? if meteor can authenticate using user name and password, then i dont need the browser session usage. Any idea how to pass the username and password and maintain the session in meteor so that subsequent api calls use that session.

actually i want to call this rest api in my meteor app. Does meteor support this?

What I’m describing below is not Meteor-specific. Neither is the error message SELF_SIGNED_CERT…

It basically means your HTTPS URL is not signed with a ‘certified’ (bought) certificate :innocent:

As the name suggests, it is ‘self-signed’. You need to add the certificate to your server’s certificate pool, or find out how to bypass certificae validation (have no idea how to do it in Meteor). Probably it’s written in the official documentation? :innocent:

They have a forum there:

But in general, REST api does not have to depend on anything. It’s all headers and parameters, e.g. query string. Possibly, this one needs a token authentication of some sort, but without seeing the documentation it’s hard to advise on anything.

This forum support this way:

var result ='GET', '', {
	npmRequestOptions: {
		auth: {
			user: 'username',
			pass: 'password'

@mrphu3074:i have tried this way but dint help, i found on the jazz forum someone has achieved using the XHR, the following is the code, how can i map it to meteor package methods.

 authorize : function(callback) {
	var xhr = contentComment.createXMLHttpRequest();'POST', contentComment.OSLC_CONTENT_TYPES.SERVICE_URL
			+ '/authenticated/identity', false);// must visit this url first
	xhr.onload = function(e) {
		if (xhr.readyState == 4 && xhr.status == 200) {
			xhrX = contentComment.createXMLHttpRequest();'POST', contentComment.OSLC_CONTENT_TYPES.SERVICE_URL
					+ '/authenticated/j_security_check', false);
			xhrX.setRequestHeader("X-Requested-With", "XMLHttpRequest");
			xhrX.setRequestHeader("Pragma", "no-cache");
			xhrX.setRequestHeader("Expires", "-1");
			// xhr.setRequestHeader("X-jazz-downstream-auth-client-level","4.0");
			xhrX.onload = function(e) {
				if (xhrX.readyState == 4 && xhrX.status == 200) {
					// log
					// on
					// success
					authrequired = xhrX
					if (authrequired == "authrequired") {
					} else if (authrequired == "authfailed") {
					} else {
			xhrX.send("j_username=" + contentComment.userName
					+ "&j_password=" + contentComment.passWord + "");
		}else if(xhr.readyState == 4){
	xhr.onerror = function(){
	xhr.ontimeout = function(){