【发布时间】:2015-08-05 20:30:42
【问题描述】:
我正在使用 FOSRestBundle 构建一个 Restful API。我有这个 POST Restful 服务的代码:
/**
* Create a new session.
* @param ParamFetcher $paramFetcher
*
* @ApiDoc(
* resource = true,
* https = true,
* description = "Create a new session",
* statusCodes = {
* 200 = "Returned when successful",
* 400 = "Returned when errors"
* }
* )
*
* @RequestParam(name="username", nullable=false, strict=true, description="The username")
* @RequestParam(name="veevaToken", nullable=false, strict=true, description="The token")
* @RequestParam(name="instanceUrl", nullable=false, strict=true, description="The instance URL")
*
* @return View
*/
public function postSessionAction(ParamFetcher $paramFetcher)
{
....
}
我将参数作为x-www-form-urlencoded 发送,我想将其更改为原始格式,例如:
{
"veevaToken": "xxxxxx",
"instanceUrl":"xxxxxx",
"username":"xxxx"
}
我该怎么做?那可能吗?有什么建议吗?
【问题讨论】:
标签: php rest symfony fosrestbundle symfony-2.6