小编Ism*_*uli的帖子

415不支持的媒体类型

当我运行此命令以查看Get方法是否正常工作时,我按照此链接检测到我的终端ERROR 415:不支持的媒体类型中显示此错误.

我要看看我的源代码:

1-首先我设置我的配置文件:

#app/config/config.yml sensio_framework_extra:view:annotations:false

fos_rest:

param_fetcher_listener: true
body_listener: true
format_listener: true
view:
    view_response_listener: 'force'
Run Code Online (Sandbox Code Playgroud)

2-我刚修好路由文件后:

#应用程序/配置/ routing.yml中

minn_ads_api:
    resource: "@MinnAdsAPIBundle/Resources/config/routing.yml"
    type: rest
Run Code Online (Sandbox Code Playgroud)

3-我还在我的*AdsAPIBundle中设置了路由文件:*

#AdsAPIBundle/Resources/config/routing.yml
brend:
    type: rest
    resource: Minn\AdsAPIBundle\Controller\BrendController
Run Code Online (Sandbox Code Playgroud)

4-在我的AdsAPIBundle下我只插入函数:

#src/BundleApi/Controller/BrendController.php
    /**
     * @Rest\View
     * @Rest\Get("/api/brend/{id}", requirements={"id" = "\d+"}, defaults={"id" = 1})
     */
    public function getAction($id) {
        $repo = $this->getDoctrine()->
                getManager()->
                getRepository("MinnAdsBundle:Brend");
        $brend = $repo->find($id);

        return array('brend' => $brend);
    }
Run Code Online (Sandbox Code Playgroud)

symfony fosrestbundle

1
推荐指数
1
解决办法
1961
查看次数

标签 统计

fosrestbundle ×1

symfony ×1