Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
Updating Twilio MediaUrl for use with Express 4

I am updating my twilio sms messaging tool to use express 4. On one one line of code I am having an issue.

var mediaUrl = request.param('MediaUrl' + i); //deprecated in express 4

When I attempt to update with this line

var mediaUrl = request.query.MediaUrl + i;

it no longer links to the twilio MediaURL. Here is the complete code for reference.

var numMedia = parseInt( request.body.NumMedia );
if (numMedia > 0) {
    for (i = 0; i < numMedia; i++) {

        //var mediaUrl = request.query.MediaUrl + i;
        var mediaUrl = request.param('MediaUrl' + i); //deprecated in express 4

        groupRef.where( {"memberNumber":request.query.From} ).limit(1).on( "value", function ( data ){
            if( data.count() ){
                data.forEach( function( snapshot ){
                    var member = snapshot.value();
                    messagesRef.push({
                        sid: request.body.MessageSid,
                        type:'text',
                        tstamp: new Date().toLocaleString('en-US', { timeZone: "America/Denver" }),
                        fromName:member.memberName,
                        fromNumber:request.body.From,
                        message:"",
                        media:mediaUrl,
                        groupNumber:request.body.To
                    });
                });
            }
        });
    }
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I think it is due to the fact that Twilio is POSTing the data to you and request.query is looking in the querystring. Either change the Twilio method to GET, or use req.body to get the value from the POST.

The simple fix would be to use:

var mediaUrl = request.body.MediaUrl + i;
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!