小编sti*_*ool的帖子

通过swagger上传文件时csrf失败

我正在尝试使用swagger上传图像文件

{"detail":"CSRF失败:CSRF令牌丢失或不正确." }

.值得一提的是,我正在使用django-rest-swagger版本0.3.0和django版本1.7.

用于上传图片的YAML如下:

parameters:
    - name: image
      in: formData
      required: true
      type: file
    - name: caption
      required: true
      type: string
Run Code Online (Sandbox Code Playgroud)

我不想使用@csrf_exempt.我试图将标题传递给此,但这不起作用.标题是这样的:

    - name: X-CSRF-Token
      description: csrftoken to be passed in header
      in: header
      required: true
      type: string
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

django swagger-ui

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

标签 统计

django ×1

swagger-ui ×1