I’m trying to create a Twilio messaging service via api as documented here: https://www.twilio.com/docs/messaging/api/service-resource#request-body-parameters
and add a phone number to it as described here: https://www.twilio.com/docs/messaging/api/phonenumber-resource#create-a-phonenumber-resource-add-a-phone-number-to-a-messaging-service.
When implemented using javascript/bash(?) it returns a messaging service starting with “MG…”
createMessagingService() {
MESSAGINGSERVICE=$(curl --location "https://messaging.twilio.com/v1/Services"
--user "${subSid}:${subAuth}"
--header "Content-Type: application/x-www-form-urlencoded"
--data-urlencode "FriendlyName=${messagingServiceName}")
messagingServiceSid=$(jq -r '.sid' <<< "${MESSAGINGSERVICE}")
echo $MESSAGINGSERVICE
}
But when I implement it using java it returns a messaging service starting with “IS…”
public Service createMessagingService(String name) {
Twilio.init(subAccount.getSid(), subAccount.getAuthToken());
Service service = Service.creator(name).create();
return service;
}
This is a problem because when trying to add a phone number to a messaging service it isn’t recognizing the “IS..” sid. It only only works for a “MG…” sid.
2024-07-31 16:19:15 SEVERE: Unexpected error occurred: The requested resource /Services/ISf.../PhoneNumbers was not found
PhoneNumber phoneNumber = PhoneNumber
.creator(messagingService.getSid(), phoneNumberSid)
.create();
Spicee Kimchee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.