Error: Invalid Response from Crowd, expecting json. while authenticating to crowd

I’m new in crowd and I have some codes to connect to crowd via a node package:

var CrowdClient = require(‘atlassian-crowd-client’);

var crowd = new CrowdClient({

baseUrl: ‘http://myhost/crowd/console/login.action’,

application: { name: ‘app’, password: ‘password’ }

});
module.exports = {
show: function (req, res) {

crowd.session.create(‘my-username’, ‘my-password’).then(function (session) { console.log('Crowd SSO token is ’ + session.token); }); }
};

but it returns Error: Invalid Response from Crowd, expecting JSON error! what should I do?

baseUrl is wrong. ‘http://myhost/crowd/console/login.action’ is not a REST endpoint, it will always return HTML, not JSON.

Your baseUrl should be ‘http://myhost/crowd’ as detailed in my answer on Atlassian community: https://community.atlassian.com/t5/Crowd-questions/how-to-authenticate-with-crowd-using-node-js/qaq-p/769829

1 Like