Skip to content

Cannot make POST request #9

@philiphacks

Description

@philiphacks

When making a POST request (i.e. sharing something or trying to send a message), I get a 401 error:

error: [Messaging] error: { statusCode: 401,
data: '\n\n 401\n 1336572233851\n Q9YREZSZ2Z\n 0\n [unauthorized]. OAU:blablabla (token etc)=\n\n' }

When trying to do a GET request, everything goes fine (i.e. getting my connections). Here is the code for the POST request:

this.userManager.getLITokens(this.email, function (err, doc) {
            if (err) {
                log.error(util.inspect(err));
            } else if (doc != null) {
                var token = crypto.decrypt(doc.token);
                var secret = crypto.decrypt(doc.secret);
                log.debug('sending message: ' + message);
                linkedin.apiCall('POST', '/people/~/shares',
                    {
                        'token': {
                            'oauth_token': token,
                            'oauth_token_secret': secret
                        },
                        // 'mailbox-item': {
                        //     'recipients' : {
                        //         'values' :
                        //             [{
                        //                 'person' : {
                        //                     '_path' : '/people/~',
                        //                 }
                        //             }]
                        //     },
                        //     'subject' : subject,
                        //     'body' : message
                        // }
                        'share' : {
                            'comment' : message,
                            'visibility' : {code: 'anyone'}
                        }
                    }, 
                    function (error, result) {
                        if (error) {
                            log.error('[Messaging] error: ' + util.inspect(error));
                            callback(error, null);
                        } else {
                            callback(null, result);
                        }
                    }
                );
            } else {
                log.error('Something has gone wrong.');
            }
        });

I don't know if this is a real issue (i.e. bug) with the library or something else is wrong. The token and secret definitely work (get the same error when I hard-code them unencrypted). Someone who knows what's wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions