DELETE方法不可调用

时间:2014-09-07 05:06:32

标签: restler

由于某些原因,我似乎无法通过Restler调用DELETE方法。在我的restler php文件中,我定义了一个类似的方法:

    /**
     * Drop invitation
     *
     * Removes an invitation from the system.  Coaches want a way to be able
     * to remove an invite if they messed up, or the person just doesn't accept.
     *
     * @param string $email The email address of the invited person {@from body}
     * @param int $team_id The SQL identifier for the team {@from body}
     *
     * @return array An empty array
     */
    public function deleteInvite($email, $team_id) {
            return [];
    }

当我试着打电话时:

  

curl -X DELETE -H" Content-Type:application / json" -d' {"电子邮件":" foo"," team_id",17}' HTTP:// server.com /应用程序/团队/邀请

它返回400错误:

  

{       "错误":{           "代码":400,           "消息":"错误请求:电子邮件丢失。"       }   }

我该怎么称呼这个?

1 个答案:

答案 0 :(得分:0)

作为一种广泛接受的做法,我们不支持/阅读GETDELETE请求的正文参数。将它们作为URL或作为查询字符串发送。

正如您在http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-26#section-4.3

中所看到的
  • HEAD - 没有定义的正文语义。
  • GET - 没有定义的正文语义。
  • PUT - 支持身体。
  • POST - 支持身体。
  • DELETE - 没有定义的正文语义。
  • 跟踪 - 支持
  • 选项 - 支持正文,但没有语义(可能在将来)。

许多http服务器都不解析GETDELETE请求的正文,restler正在遵循这种做法