我正在使用 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"
}
我该怎么做?那可能吗?有什么建议吗?