Skip to content

Get an error "invalid character '-' in numeric literal\n\nrequest body: " when using formData. #2491

@hrsma2i

Description

@hrsma2i

Problem statement

I set a request parameter as formData and get the following error.

invalid character '-' in numeric literal\n\nrequest body: \"--------------------------2d70d43748b1608c\r\nContent-Disposition: form-data; name=\"user_id\"\r\n\r\n123\r\n--------------------------2d70d43748b1608c--\r\n\"\n

Swagger specification

swagger: "2.0"
consumes:
  - application/json
produces:
  - application/json
schemes:
  - http
paths:
  /v1/users:
    post:
      operationId: postUser
      consumes:
        - multipart/form-data
      parameters:
        - name: image
          type: file
          in: formData
        - name: user_id
          type: integer
          format: int64
          in: formData
          required: true

Steps to reproduce

Execute the following commands.

# Set up the server
$ go run ./cmd/myapp-server/main.go --host 0.0.0.0 --port 8080

# Request
$ curl -X POST \
    -H "Content-Type: multipart/form-data" \
    -F user_id=123 \
    http://localhost:8080/v1/users

Environment

swagger version: 0.25.0
go version: 1.15.6
OS: macOS Catalina 10.15.7

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions