Hello everyone, I am using node js to connect to the twitter api, to be more specific to direct messages, but still returning the same error code 32, then attached the code, in the documentation of the api they mention that they should use headers to make the request, I want to know if that is my problem. thanks

const twitter = require('twitter');
            const client = new twitter({
                consumer_key: '...',
                consumer_secret: '.',
                access_token_key: '....',
                access_token_secret: '....'
            });

            client.post('direct_messages/events/new', {
                headers: {
                    'Content-Type': 'application/json',
                    'Content-Length': 'application/json',
                },
                event: {
                    type: "message_create",
                    message_create: {
                        target: {
                            recipient_id: "nodejs"
                        },
                        message_data: {
                            text: "message"
                        }
                    }
                }
            }, (error: any, event: any)=>{
                    if(error){
                      console.log(error)
                    }
                    else{
                       console.log(event);
                    }
            })

Error 32 means that you are probably having issues passing along the proper keys and tokens or authorizing your request. I suggest that you make sure to check the following:

  1. you are using the proper auth keys for this endpoint, which you can identify via the endpoint’s api reference page. It might help to review our authentication section for more details on this.
  2. you have properly generated the oauth nonce , oauth_signature , and oauth_timestamp for your request.

If you have properly set up your keys and tokens, then chances are that you aren’t handling number two properly. If so, please consider using an oauth library (example), Insomnia, or try using Twurl.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.