# PetApi All URIs are relative to *http://petstore.swagger.io/v2* | Method | HTTP request | Description | |------------- | ------------- | -------------| | [**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store | | [**addPetWithHttpInfo**](PetApi.md#addPetWithHttpInfo) | **POST** /pet | Add a new pet to the store | ## addPet > Pet addPet(pet) Add a new pet to the store ### Example ```java // Import classes: import org.openapitools.client.ApiClient; import org.openapitools.client.ApiException; import org.openapitools.client.Configuration; import org.openapitools.client.auth.*; import org.openapitools.client.models.*; import org.openapitools.client.api.PetApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://petstore.swagger.io/v2"); // Configure OAuth2 access token for authorization: petstore_auth OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(defaultClient); Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store try { Pet result = apiInstance.addPet(pet); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling PetApi#addPet"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` ### Parameters | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| | **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | ### Return type [**Pet**](Pet.md) ### Authorization [petstore_auth](../README.md#petstore_auth) ### HTTP request headers - **Content-Type**: application/json, application/xml - **Accept**: application/xml, application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | successful operation | - | | **405** | Invalid input | - | ## addPetWithHttpInfo > ApiResponse addPet addPetWithHttpInfo(pet) Add a new pet to the store ### Example ```java // Import classes: import org.openapitools.client.ApiClient; import org.openapitools.client.ApiException; import org.openapitools.client.ApiResponse; import org.openapitools.client.Configuration; import org.openapitools.client.auth.*; import org.openapitools.client.models.*; import org.openapitools.client.api.PetApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://petstore.swagger.io/v2"); // Configure OAuth2 access token for authorization: petstore_auth OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(defaultClient); Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store try { ApiResponse response = apiInstance.addPetWithHttpInfo(pet); System.out.println("Status code: " + response.getStatusCode()); System.out.println("Response headers: " + response.getHeaders()); System.out.println("Response body: " + response.getData()); } catch (ApiException e) { System.err.println("Exception when calling PetApi#addPet"); System.err.println("Status code: " + e.getCode()); System.err.println("Response headers: " + e.getResponseHeaders()); System.err.println("Reason: " + e.getResponseBody()); e.printStackTrace(); } } } ``` ### Parameters | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| | **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | | ### Return type ApiResponse<[**Pet**](Pet.md)> ### Authorization [petstore_auth](../README.md#petstore_auth) ### HTTP request headers - **Content-Type**: application/json, application/xml - **Accept**: application/xml, application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| | **200** | successful operation | - | | **405** | Invalid input | - |