skip to Main Content

i used the following function and trying to run HTTP request from postman using curl but didn’t work

exports.handler = function(context, event, callback) {
    const client = context.getTwilioClient();
    const new_fallback_url = 'http://your_twilio_function_url.com/webhooks/twilio_voice_fallback'; // Replace with your actual Twilio Function URL

    // Fetch all phone numbers and update them
    client.incomingPhoneNumbers.list()
        .then(phoneNumbers => {
            const updates = phoneNumbers.map(number => {
                return client.incomingPhoneNumbers(number.sid)
                    .update({ voiceFallbackUrl: new_fallback_url });
            });
            return Promise.all(updates);
        })
        .then(results => {
            callback(null, `Fallback URL updated for ${results.length} numbers`);
        })
        .catch(error => {
            callback(error);
        });
};

I want after running the code all my twilio number will automatically updated

2

Answers


  1. Chosen as BEST ANSWER

    Done thank you i found the solution


  2. Please attach the output of your postman/ cURL request so others can see what the actual error/issue is. Other than that there are a couple things to keep in mind.

    1. Did you deploy the function?
    2. Is the function deployed as a ‘Public’ asset? If it is ‘Private’ or ‘Protected’ then you will get an 401/403 Unauthorized error in the response.
    3. It looks like the code you provided is possibly AI generated, make sure that it meets your requirements and is syntactically correct for your desired application.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search