I am trying to update my sim fleet name and sim unique name without any success
const url = `https://supersim.twilio.com/v1/Sims/${sid}? fleet=${fleet}&uniqueName=${uniqueName}`;
const resp = await fetch(url, {
method: "POST",
headers: new Headers({
Authorization: auth.twilioAuth,
"Content-Type": "application/x-www-form-urlencoded",
}),
body: new URLSearchParams({
Iccid: iccid,
}).toString(),
});
I get a 200 response with my sim object as follows
account_sid: "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
date_created: "2022-01-08T21:05:00Z"
date_updated: "2022-01-08T21:05:00Z"
fleet_sid: null //did not update
iccid: "XXXXXXXXXXXXX"
links: {billing_periods: 'https://supersim.twilio.com/v1/Sims/HSXXXXXXXXXXXXXXXXXXXXXXXX/BillingPeriods'}
sid: "HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
status: "new"
unique_name: null //did not update
url: "https://supersim.twilio.com/v1/Sims/HSXXXXXXXXXXXXXXXXXXXXXXXXXXX"
and this is what their CURL example website says
curl -X POST https://wireless.twilio.com/v1/Sims/DEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
--data-urlencode "CallbackMethod=POST" \
--data-urlencode "CallbackUrl=https://sim-manager.mycompany.com/sim-update-callback/AliceSmithSmartMeter" \
--data-urlencode "Status=active" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
You should send the parameters you want to update in the body of the request, not in the query parameters. Also note that the parameter names are in Pascal case. Try this:
const url = `https://supersim.twilio.com/v1/Sims/${sid}`;
const resp = await fetch(url, {
method: "POST",
headers: new Headers({
Authorization: auth.twilioAuth,
"Content-Type": "application/x-www-form-urlencoded",
}),
body: new URLSearchParams({
Iccid: iccid,
Fleet: fleet,
UniqueName: uniqueName
}).toString(),
});