【问题标题】:Post in R Plumber keeps giving error message在 R Plumber 中的帖子不断给出错误信息
【发布时间】:2020-07-25 03:01:14
【问题描述】:

我正在尝试将一些值发布到管道工 (0.4.6) API,但我不断收到以下错误:

错误

<simpleError in (function (orgName, reportType, teamCode) {    code <- teamCode    org <- orgName})(): argument "teamCode" is missing, with no default>

管道工 API 路由

#* @apiTitle Set team codes
#* @post /report
function(orgName, reportType, teamCode){
  
  code <- teamCode
  org <- orgName
  
}

Fiddler 显示 POST 期间发送的数据

我根据文档和 SO 问题尝试了其他一些方法,但这些方法也不起作用。所以,我不确定发生了什么以及为什么它不处理请求。我不明白错误的含义。

【问题讨论】:

    标签: r post plumber


    【解决方案1】:

    express.js 我也遇到过类似的问题。我不知道您是如何发送数据的,因为您没有显示它。但似乎您发送发布请求的方式可能没有正确格式化数据 - 特别是因为@BrunoTremblay 能够使用httr 发布请求。您的express.js 发布请求至少应该包含标题、网址和表单。

    var request = require('request');
    
    request.post({
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        url: 'http://localhost:7667/report',
        form: req.body
      }, (error, response, body) => {
        if (error) {
          console.log(error)
          return
        }
    

    我尚未对其进行测试,但希望这能让您了解您的请求是否也以相同的方式配置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-23
      • 2022-01-25
      • 1970-01-01
      • 2015-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-30
      相关资源
      最近更新 更多