---
title: Place an order for a pet
slug: docs/demo/place-an-order-for-a-pet
description: Learn how to use the curl command to make a POST request to a targeted URL with this code snippet. The snippet comes with headers for handling JSON data and a data payload that contains multiple essential fields like id, petId, quantity, shipDate, status,
docTags: 
createdAt: 2022-11-25T15:11:39.000Z
---

{
  "id": "ylvueKXE0HnQs41pa7BUN",
  "data": {
    "url": "https://petstore.swagger.io/v2/store/order",
    "name": "Place an order for a pet",
    "method": "POST",
    "request": {
      "pathParameters": [],
      "queryParameters": [],
      "headerParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "schema": [
            {
              "kind": "optional",
              "name": "id",
              "type": "integer<int64>",
              "example": 0
            },
            {
              "kind": "optional",
              "name": "petId",
              "type": "integer<int64>",
              "example": 0
            },
            {
              "kind": "optional",
              "name": "quantity",
              "type": "integer<int32>",
              "example": 0
            },
            {
              "kind": "optional",
              "name": "shipDate",
              "type": "string<date-time>",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "status",
              "type": "string<placed | approved | delivered>",
              "example": "",
              "description": "Order Status"
            },
            {
              "kind": "optional",
              "name": "complete",
              "type": "boolean",
              "example": ""
            }
          ],
          "modelRef": "#/definitions/Order",
          "customType": "Order",
          "isExpanded": true
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "schema": [
              {
                "kind": "optional",
                "name": "id",
                "type": "integer<int64>",
                "example": 0
              },
              {
                "kind": "optional",
                "name": "petId",
                "type": "integer<int64>",
                "example": 0
              },
              {
                "kind": "optional",
                "name": "quantity",
                "type": "integer<int32>",
                "example": 0
              },
              {
                "kind": "optional",
                "name": "shipDate",
                "type": "string<date-time>",
                "example": ""
              },
              {
                "kind": "optional",
                "name": "status",
                "type": "string<placed | approved | delivered>",
                "example": "",
                "description": "Order Status"
              },
              {
                "kind": "optional",
                "name": "complete",
                "type": "boolean",
                "example": ""
              }
            ],
            "modelRef": "#/definitions/Order",
            "customType": "Order",
            "isExpanded": true
          }
        ],
        "isExpanded": true,
        "statusCode": "200",
        "description": "successful operation",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "400",
        "description": "Invalid Order",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "",
    "examples": {
      "languages": [
        {
          "id": "wo8kqi-BZoeKCOzUUd12y",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://petstore.swagger.io/v2/store/order \\\n     --header 'accept: application/json'"
        },
        {
          "id": "BZOspyBWGnO3C0Z5n3Z-G",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://petstore.swagger.io/v2/store/order\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "6P7DmgiOLpWOGgcnslAZh",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://petstore.swagger.io/v2/store/order\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "9rbB1oXhNYFDy4fcQu_1_",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://petstore.swagger.io/v2/store/order\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "wo8kqi-BZoeKCOzUUd12y"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// successful operation\n{\n  \"id\": \"\",\n  \"petId\": \"\",\n  \"quantity\": \"\",\n  \"shipDate\": \"\",\n  \"status\": \"\",\n  \"complete\": false\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Invalid Order\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}