Send data via header using OpenApi 3 with method GET
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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"
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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. ⬇️⬇️⬇️
