I don't know how to send the curl -u in node js i try the following code but no luck.
request({
url: "https://preview.twilio.com/HostedNumbers/HostedNumberOrders",
method: "POST",
json: true,
headers: {
"content-type": "application/json",
"Authorization": accountSid + authToken
},
json: {
"PhoneNumber": payload.phonenumber, "SmsCapability": true, "IsoCountry": payload.isocountry,
"AddressSid": address.sid, "Email": payload.email,
"FriendlyName": payload.friendlyname, "StatusCallbackUrl": "http://example.com/callback",
"StatusCallbackMethod": "POST",
},
}, function (error, response, body) {
res.json({ 'error': error, 'data': response, 'body': body });
return true;
})
this is the curl which i want to call.
curl -XPOST https://preview.twilio.com/HostedNumbers/HostedNumberOrders \
-d "PhoneNumber=+18312011484" \
-d "SmsCapability=true" \
-d "IsoCountry=US" \
-d "AddressSid=ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-d "Email=hostedsms@twilio.com" \
-d "FriendlyName=HostedNumberOrder1" \
-d "StatusCallbackUrl=http://example.com/callback" \
-d "StatusCallbackMethod=POST" \
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'