Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add member to specific group not returning anything #2

Open
mattfili opened this issue Feb 21, 2016 · 3 comments
Open

Add member to specific group not returning anything #2

mattfili opened this issue Feb 21, 2016 · 3 comments

Comments

@mattfili
Copy link

I'm trying to add a member to a specific group and I'm not able to return anything / not getting any errors.

I'm wondering if I'm passing in data without the right headers, or maybe poor format.

var Emma = require('emma-sdk');
var localConfig = require('../../config/local.env');

var operatorInfo = {
        "fields" : {
            "first_name": req.body.init_firstname,
            "last_name": req.body.init_lastname,
        },
        "email": res.body.email
}


var emma = new Emma({
    publicKey: localConfig.emmaKey.publicKey,
    privateKey: localConfig.emmaKey.privateKey,
    accountID: localConfig.emmaKey.accountID
})


emma.member.withID(groupId).groups.add(JSON.stringify(operatorInfo), function(err, result){
    console.log(err)
    console.log(result);
    return result;
})
@nathanpeck
Copy link
Owner

The request module which this API wrapper is built on will automatically
stringify JS objects. I believe that your JSON stringify is causing the
problem. Try passing in a plain JS object.

Hopefully this works for you, but unfortunately I no longer have access to
an Emma account to test with. I made this module back when I was working at
a startup that was using Emma but now haven't used it in nearly two years.
On Sun, Feb 21, 2016 at 3:36 AM Matt Fili [email protected] wrote:

I'm trying to add a member to a specific group and I'm not able to return
anything / not getting any errors.

I'm wondering if I'm passing in data without the right headers, or maybe
poor format.

`var Emma = require('emma-sdk');
var localConfig = require('../../config/local.env');

var operatorInfo = {
"fields" : {
"first_name": req.body.init_firstname,
"last_name": req.body.init_lastname,
},
"email": res.body.email
}

var emma = new Emma({
publicKey: localConfig.emmaKey.publicKey,
privateKey: localConfig.emmaKey.privateKey,
accountID: localConfig.emmaKey.accountID
})

emma.member.withID(groupId).groups.add(JSON.stringify(operatorInfo),
function(err, result){
console.log(err)
console.log(result);
return result;
})`


Reply to this email directly or view it on GitHub
#2.

@mattfili
Copy link
Author

I downgraded to the hackiest method possible and can't get it working with a pure request

`   var operatorInfo = {
        fields : {
            first_name: 'andrea',
            last_name: 'smith'
        },
        email: '[email protected]',
        group_ids: [settings.groupId]
    }

    request({
        url: 'https://api.e2ma.net/1755632/members/add',
        headers: {
            'Authorization': "Basic " + new Buffer(settings.publicKey + ':' + settings.privateKey).toString("base64"),
            'Content-Type': 'application/json'
        },
        body: operatorInfo,
        method: 'POST'
    }, function (err, body, res) {
        console.log(err)
        console.log(body)
        console.log(res)
    })`

@nathanpeck
Copy link
Owner

Huh yeah I can't help you with that then... They might have changed their
API or have some issue in their service that they need to fix. I'd
recommend opening a ticket with Emma support.
On Sun, Feb 21, 2016 at 9:00 AM Matt Fili [email protected] wrote:

I downgraded to the hackiest method possible and can't get it working with
a pure request
` var operatorInfo = {
fields : {
first_name: 'andrea',
last_name: 'smith'
},
email: '[email protected]',
group_ids: [settings.groupId]
}

request({
url: 'https://api.e2ma.net/1755632/members/add',
headers: {
'Authorization': "Basic " + new Buffer(settings.publicKey + ':' + settings.privateKey).toString("base64"),
'Content-Type': 'application/json'
},
body: operatorInfo,
method: 'POST'
}, function (err, body, res) {
console.log(err)
console.log(body)
console.log(res)
})`


Reply to this email directly or view it on GitHub
#2 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants