【问题标题】:Sending a Post request in postman pre-script在 postman pre-script 中发送 Post 请求
【发布时间】:2020-09-28 07:17:24
【问题描述】:

我正在尝试使用邮递员在预脚本中发送 POST 请求,但出现错误“评估预请求脚本时出错:错误:1:1 ^ 时出现意外令牌'

pm.sendRequest({
url: 'http://localhost:8001/routes/d6b7a95a-fd91-4f8a-b8f6-10835f30170a',
method: 'PATCH',
headers: {"Content-Type": "application/json"},
body: { 
    mode: 'raw',
    raw:JSON.stringify({
        "protocols":["http","https"],
        "paths":["/target-paymentoriginal"],
        "methods":[]})}  }, 

function (err, response) {  console.log("Updated original route to target-payment"+response.json());  });

【问题讨论】:

  • 您如何尝试header: {"Content-Type": "application/json"} - 从您的代码中删除s
  • @DannyDainton 感谢您指出这一点。它现在工作。拯救我的一天。
  • 添加了答案,以便您接受并结束问题。 ??????

标签: postman postman-pre-request-script


【解决方案1】:

指定headers 的键不正确。

应该是:

header: {"Content-Type": "application/json"} -

您需要从代码中删除s

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-10
    • 2019-03-09
    • 2021-05-11
    • 2019-09-12
    • 1970-01-01
    • 2021-06-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多