addPet
Add a new pet to the store
/pet
Usage and SDK Samples
curl -X POST \
\
-H "Accept: application/xml,application/json" \
-H "Content-Type: application/json,application/xml" \
"http://petstore.swagger.io/v2/pet" \
-d '{
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
"category" : {
"name" : "name",
"id" : 6
},
"tags" : [ {
"name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1
} ],
"status" : "available"
}' \
-d '<Pet>
<id>123456789</id>
<name>doggie</name>
<photoUrls>
<photoUrls>aeiou</photoUrls>
</photoUrls>
<tags>
</tags>
<status>aeiou</status>
</Pet>'
import Ally\PetStore.*;
import Ally\PetStore.auth.*;
import Ally\PetStore.model.*;
import Ally\PetStore.api.PetApi;
import java.io.File;
import java.util.*;
public class PetApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: petstore_auth
OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth");
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");
// Create an instance of the API class
PetApi apiInstance = new PetApi();
Pet pet = ; // Pet |
try {
Pet result = apiInstance.addPet(pet);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PetApi#addPet");
e.printStackTrace();
}
}
}
import Ally\PetStore.api.PetApi;
public class PetApiExample {
public static void main(String[] args) {
PetApi apiInstance = new PetApi();
Pet pet = ; // Pet |
try {
Pet result = apiInstance.addPet(pet);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PetApi#addPet");
e.printStackTrace();
}
}
}
Configuration *apiConfig = [Configuration sharedConfig];
// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth)
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];
// Create an instance of the API class
PetApi *apiInstance = [[PetApi alloc] init];
Pet *pet = ; //
// Add a new pet to the store
[apiInstance addPetWith:pet
completionHandler: ^(Pet output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
var OpenApiPetstore = require('open_api_petstore');
var defaultClient = OpenApiPetstore.ApiClient.instance;
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = "YOUR ACCESS TOKEN";
// Create an instance of the API class
var api = new OpenApiPetstore.PetApi()
var pet = ; // {Pet}
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.addPet(pet, callback);
using System;
using System.Diagnostics;
using pet-store-api-sdk.Api;
using pet-store-api-sdk.Client;
using pet-store-api-sdk.Model;
namespace Example
{
public class addPetExample
{
public void main()
{
// Configure OAuth2 access token for authorization: petstore_auth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
// Create an instance of the API class
var apiInstance = new PetApi();
var pet = new Pet(); // Pet |
try {
// Add a new pet to the store
Pet result = apiInstance.addPet(pet);
Debug.WriteLine(result);
} catch (Exception e) {
Debug.Print("Exception when calling PetApi.addPet: " + e.Message );
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
Ally\PetStore\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
// Create an instance of the API class
$api_instance = new OpenAPITools\Client\Api\PetApi();
$pet = ; // Pet |
try {
$result = $api_instance->addPet($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::OPenAPIClient::Configuration;
use WWW::OPenAPIClient::PetApi;
# Configure OAuth2 access token for authorization: petstore_auth
$WWW::OPenAPIClient::Configuration::access_token = 'YOUR_ACCESS_TOKEN';
# Create an instance of the API class
my $api_instance = WWW::OPenAPIClient::PetApi->new();
my $pet = WWW::OPenAPIClient::Object::Pet->new(); # Pet |
eval {
my $result = $api_instance->addPet(pet => $pet);
print Dumper($result);
};
if ($@) {
warn "Exception when calling PetApi->addPet: $@\n";
}
from __future__ import print_statement
import time
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Configure OAuth2 access token for authorization: petstore_auth
openapi_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Create an instance of the API class
api_instance = openapi_client.PetApi()
pet = # Pet |
try:
# Add a new pet to the store
api_response = api_instance.add_pet(pet)
pprint(api_response)
except ApiException as e:
print("Exception when calling PetApi->addPet: %s\n" % e)
extern crate PetApi;
pub fn main() {
let pet = ; // Pet
let mut context = PetApi::Context::default();
let result = client.addPet(pet, &context).wait();
println!("{:?}", result);
}
Scopes
write:pets | modify pets in your account |
read:pets | read your pets |
Parameters
Name | Description |
---|---|
pet * |
Pet object that needs to be added to the store |