Add a new pet to the store
1 min
POST
https://petstore3.swagger.io/api/v3/pet
Body Parameters
- bodyPetrequiredDescription
- idinteger<int64>Example
- namestringrequiredExample
- categoryCategory
- idinteger<int64>Example
- namestringExample
- photoUrlsstring[]required
- tagsTag[]
- idinteger<int64>
- namestring
- statusstring<available | pending | sold>Description
Form Parameters
- idinteger<int64>Example
- namestringrequiredExample
- categoryCategory
- idinteger<int64>Example
- namestringExample
- photoUrlsstring[]required
- tagsTag[]
- idinteger<int64>
- namestring
- statusstring<available | pending | sold>Description
Responses
200
- Pet
- idinteger<int64>Example
- namestringrequiredExample
- categoryCategory
- idinteger<int64>Example
- namestringExample
- photoUrlsstring[]required
- tagsTag[]
- idinteger<int64>
- namestring
- statusstring<available | pending | sold>Description
405
curl
curl --location 'https://petstore3.swagger.io/api/v3/pet' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"id": 0,
"name": "",
"category": {
"id": 0,
"name": ""
},
"photoUrls": [
""
],
"tags": [
{
"id": 0,
"name": ""
}
],
"status": ""
}'javascript
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"id": 0,
"name": "",
"category": {
"id": 0,
"name": ""
},
"photoUrls": [
""
],
"tags": [
{
"id": 0,
"name": ""
}
],
"status": ""
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://petstore3.swagger.io/api/v3/pet", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "json"
require "net/http"
url = URI("https://petstore3.swagger.io/api/v3/pet")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"id": 0,
"name": "",
"category": {
"id": 0,
"name": ""
},
"photoUrls": [
""
],
"tags": [
{
"id": 0,
"name": ""
}
],
"status": ""
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://petstore3.swagger.io/api/v3/pet"
payload = json.dumps({
"id": 0,
"name": "",
"category": {
"id": 0,
"name": ""
},
"photoUrls": [
""
],
"tags": [
{
"id": 0,
"name": ""
}
],
"status": ""
})
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
200
// Successful operation
{
"id": 10,
"name": "doggie",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
""
],
"tags": [
{
"id": "",
"name": ""
}
],
"status": ""
}405
// Invalid input
This is a very long sentence that spans several lines in the YAML but which will be rendered as a string with newlines preserved.
Hints
## 2asdasdas
asdas asd We would love you to contribute to `@octokit/rest`, pull requests are very welcome! Please see CONTRIBUTING.md for more information.Have a question?
Our super-smart AI, knowledgeable support team and an awesome community will get you an answer in a flash.
To ask a question or participate in discussions, you'll need to authenticate first.