Why can’t I upload config file in the POST method using Postman?

Hello, I’m trying to solve my issue for so long that I had to ask someone else.

I’m working with some API and I want to create resource using POST method via Postman. To create that resource I have to attach kubeconfig file to the POST request. This resource need to have name, description and of course config file. So I filled required fields:

POSTMAN fields

but I receive response “Bad Request”:

Invalid Input:: Does not match pattern '^([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$'

It’s look like i don’t understand how to upload files that way because my request body looks like:

Request Body
    metadata: "{"name": "edge01", "description": "Edge k8s cluster"}"
    file: undefine

In the API documentation we can find that request body should look like this:

Request body                                                     multipart/form-data



Entire POST entry below:

Request Headers
    Accept: */*
    Postman-Token: 8857f718-bb05-404c-865a-51ee3c0abe6f
    Host: <Hidden_IP>:30461
    Accept-Encoding: gzip, deflate, br
    Connection: keep-alive
    Content-Type: multipart/form-data; boundary=--------------------------175308278007362265143565
    Content-Length: 3518
Request Body
    metadata: "{"name": "edge01", "description": "Edge k8s cluster"}"
    file: undefined
Response Headers
    Content-Type: text/plain; charset=utf-8
    X-Content-Type-Options: nosniff
    Date: Fri, 30 Jul 2021 10:19:58 GMT
    Content-Length: 84
Response Body
    Invalid Input:: Does not match pattern '^([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$'↵

I couldn’t find anything about response presented above.

If anyone needs additional information, please comment. This string($binary) is interesting but I don’t understand what it means, and couldn’t find any informations in POSTMAN context.

This is a piece of API yaml:

  - $ref: '#/components/parameters/clusterProviderName'
    - Clusters
  summary: Add Cluster
  description: Add a new `cluster`
  operationId: addClusterToClusterProvider
      description: Created
        application/json: # operation response mime type
            $ref: '#/components/schemas/Metadata'
      description: Bad Request
      description: Not Found
      description: Conflict
      description: Unprocessable Entity
      description: Internal Server Error
      multipart/form-data: # Media type
        schema:            # Request payload
          $ref: '#/components/schemas/AppData'

Add metadata to the body under raw, instead of form-data. This should be an object, like this:

    "metadata": {
        "name": "edge01",
        "description": "Edge k8s cluster"

Leave a Comment