Code Samples #
Copy
curl --request POST \
--url '/api/v3/store/order' \
--header 'Content-Type: application/json' \
--data '{
"id": 10,
"petId": 198772,
"quantity": 7,
"shipDate": "2024-01-15T09:30:00Z",
"status": "approved",
"complete": true
}'
const response = await fetch('/api/v3/store/order', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"id": 10,
"petId": 198772,
"quantity": 7,
"shipDate": "2024-01-15T09:30:00Z",
"status": "approved",
"complete": true
})
});
const data = await response.json();
console.log(data);
import requests
headers = {
"Content-Type": "application/json"
}
payload = {
"id": 10,
"petId": 198772,
"quantity": 7,
"shipDate": "2024-01-15T09:30:00Z",
"status": "approved",
"complete": true
}
response = requests.post("/api/v3/store/order", headers=headers, json=payload)
print(response.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => '/api/v3/store/order',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => '{
"id": 10,
"petId": 198772,
"quantity": 7,
"shipDate": "2024-01-15T09:30:00Z",
"status": "approved",
"complete": true
}',
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
using System.Net.Http;
using System.Text;
var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "/api/v3/store/order");
request.Content = new StringContent(@"{
""id"": 10,
""petId"": 198772,
""quantity"": 7,
""shipDate"": ""2024-01-15T09:30:00Z"",
""status"": ""approved"",
""complete"": true
}", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
import java.net.URI;
import java.net.http.*;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("/api/v3/store/order"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"id": 10,
"petId": 198772,
"quantity": 7,
"shipDate": "2024-01-15T09:30:00Z",
"status": "approved",
"complete": true
}
"""))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Place A new order in the store.
Request Body #
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
id | integer (int64) | Optional | |
petId | integer (int64) | Optional | |
quantity | integer (int32) | Optional | |
shipDate | string (date-time) | Optional | |
status | string | Optional | Order Status Allowed: placed, approved, delivered |
complete | boolean | Optional |
Example request
Copy
{
"id": 10,
"petId": 198772,
"quantity": 7,
"shipDate": "2024-01-15T09:30:00Z",
"status": "approved",
"complete": true
}
Responses #
200 — successful operation #
| Field | Type | Required | Description |
|---|---|---|---|
id | integer (int64) | Optional | |
petId | integer (int64) | Optional | |
quantity | integer (int32) | Optional | |
shipDate | string (date-time) | Optional | |
status | string | Optional | Order Status Allowed: placed, approved, delivered |
complete | boolean | Optional |
Example 200 response
Copy
{
"id": 10,
"petId": 198772,
"quantity": 7,
"shipDate": "2024-01-15T09:30:00Z",
"status": "approved",
"complete": true
}
400 — Invalid input #
422 — Validation exception #
default — Unexpected error #
Response #
200
{
"id": 10,
"petId": 198772,
"quantity": 7,
"shipDate": "2024-01-15T09:30:00Z",
"status": "approved",
"complete": true
}