cancel
Showing results for 
Search instead for 
Did you mean: 

Send data via header using OpenApi 3 with method GET

Highlighted
New Contributor

Send data via header using OpenApi 3 with method GET

Hello!

Would anyone know how to help me send data via header using the get method in OpenApi 3?

Code that doesn't work:

 

/version:
get:
    tags:
    - "version"
    summary: ""
    description: ""
    parameters:
    - name: "Content-Type"
      in: "header"
      description: ""
      required: true
      content:
          application / xml:
              schema:
                  type: string

 

In version 2 I can do it well.

working code:

 

get:
    tags:
    - "version"
    summary: ""
    description: ""
    produces:
    - "application / xml"
    parameters:
    - name: "Content-Type"
      in: "header"
      description: ""
      required: true
      type: "string"
    responses:
        "200":
            description: "successful operation"
        "400":
            description: "Invalid status value"

3 REPLIES 3
Highlighted
Moderator

Re: Send data via header using OpenApi 3 with method GET

Hi @vitorlima1602,

Can you please clarify why you need the Content-Type header in a GET request? Content-Type is used in requests that have a request body, such as POST, PUT, or PATCH. GET requests are not supposed to have a body, this is explicitly disallowed in OpenAPI 3.0.


Helen Kosova
SmartBear Documentation Team Lead
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
New Contributor

Re: Send data via header using OpenApi 3 with method GET

Hi.

It is that in the company where I work, they adopted a standard of trafficking data through the header, including several GET methods are working like this, people test via postman and it works normally.

Now they want to use the swagger accessing the routes in the same way and I don't know how to do that.

Highlighted
Moderator

Re: Send data via header using OpenApi 3 with method GET

You can have header parameters, just not the ones named Content-Type or Accept - these headers are derived from request and response media types. Check out the Describing Parameters guide, it has some examples.


Helen Kosova
SmartBear Documentation Team Lead
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors
Top Kudoed Posts