0

I want to upload image file. Swagger 2.0 code for upload

/upload:
post:
   summary: Uploads a file.
   consumes:
     - multipart/form-data
   produces:
     - application/json
   parameters:
     - name: image
       in: formData
       required: false
       type: file
       description: The file to upload.
   responses:
      '200':
        description: OK (successfully uploaded)
      '500':
        description: Error importing file

I am testing this through postman were in body I have mentioned "form-data" key: "image" value :"Image file"

I am receiving following error

{
    "statusCode": 400,
    "error": "Bad Request",
    "message": "child \"image\" fails because [\"value\" must be a string]",
    "validation": {
        "source": "payload",
        "keys": [
            "image"
        ]
    }
}
simon-p-r
  • 3,623
  • 2
  • 20
  • 35
Asmita0915
  • 57
  • 1
  • 8
  • Is the Swagger spec correct, that is, does your server actually expect `multipart/form-data`? If this is correct, make sure you configured the request correctly in Postman - [see here](https://stackoverflow.com/a/16022213/113116). – Helen Jan 02 '18 at 22:36
  • thanks issue is resolved, just changed format to "binary" it was taking as string – Asmita0915 Jan 08 '18 at 08:07

0 Answers0