gpt4 book ai didi

javascript - 从 CURL 示例实现 Twilio Api 调用到 js 返回状态代码 200 但似乎没有更新数据

转载 作者:行者123 更新时间:2023-12-05 05:42:27 25 4
gpt4 key购买 nike

我正在尝试更新我的 sim 机队名称和 sim 唯一名称但没有成功

  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(),
});

我的 sim 对象收到 200 响应,如下所示

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"


Twilio documentation

这就是他们的 CURL 示例网站所说的

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

最佳答案

您应该在请求正文中发送要更新的参数,而不是在查询参数中。另请注意 the parameter namesPascal case .试试这个:

  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(),
});

关于javascript - 从 CURL 示例实现 Twilio Api 调用到 js 返回状态代码 200 但似乎没有更新数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72025777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com