如何构造restful API的POST请求

时间:2016-06-10 02:28:30

标签: php api rest post restful-architecture

目前我有一个API:

http://testing2.pehk.com.hk/data/PEP/kiddieworld/phase2/pep_web7/web/index.php/kiddieworldapi/appGetTeacherInfo

如果您发布“userid = 544”,那么它将成功返回数据,如下面的屏幕截图所示。

enter image description here

但是,我尝试在POST参数或Body中添加了544的userid,它仍然返回500内部服务器错误。我确信API很好,唯一的问题是请求的结构。

enter image description here

如何构建POST请求?请随意测试上面的API链接。感谢。

1 个答案:

答案 0 :(得分:1)

看起来您必须在屏幕截图中显示一些信息。

Content-Type:application/x-www-form-urlencoded