---
title: Updated user
slug: docs/demo/updated-user
description: Learn how to make a PUT request to a specific API endpoint using this code example. The request includes essential parameters like username, firstName, lastName, email, password, phone, and userStatus. The request and response are both expected to be in J
docTags: 
createdAt: 2022-11-25T15:11:39.000Z
---

{
  "id": "BxIOSgSLFNJyOFLLNwXoW",
  "data": {
    "url": "https://petstore.swagger.io/v2/user/{username}",
    "name": "Updated user",
    "method": "PUT",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "username",
          "type": "string",
          "description": "name that need to be updated"
        }
      ],
      "queryParameters": [],
      "headerParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "schema": [
            {
              "kind": "optional",
              "name": "id",
              "type": "integer<int64>",
              "example": 0
            },
            {
              "kind": "optional",
              "name": "username",
              "type": "string",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "firstName",
              "type": "string",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "lastName",
              "type": "string",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "email",
              "type": "string",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "password",
              "type": "string",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "phone",
              "type": "string",
              "example": ""
            },
            {
              "kind": "optional",
              "name": "userStatus",
              "type": "integer<int32>",
              "example": 0,
              "description": "User Status"
            }
          ],
          "modelRef": "#/definitions/User",
          "customType": "User",
          "isExpanded": true
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "isExpanded": true,
        "statusCode": "400",
        "description": "Invalid user supplied",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "404",
        "description": "User not found",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "This can only be done by the logged in user.",
    "examples": {
      "languages": [
        {
          "id": "8fiJ_U821XDp2Cv7k2Pj0",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request PUT \\\n     --url https://petstore.swagger.io/v2/user/{username} \\\n     --header 'accept: application/json'"
        },
        {
          "id": "GfihS3LHlO7JnPRYWoJx1",
          "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: 'PUT',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://petstore.swagger.io/v2/user/{username}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "ZYAqvuwn9PI7zSFkdukTX",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://petstore.swagger.io/v2/user/{username}\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Put.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "hvykrch8Uuh6QzL-hVIfZ",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://petstore.swagger.io/v2/user/{username}\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"PUT\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "8fiJ_U821XDp2Cv7k2Pj0"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-400",
          "language": "400",
          "code": "// Invalid user supplied\n"
        },
        {
          "id": "response-1-404",
          "language": "404",
          "code": "// User not found\n"
        }
      ],
      "selectedLanguageId": "response-0-400"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}