1

I am experimenting with API testing but I am stuck almost at the beginning. Please tell me maybe I am doing something wrong?

  1. On the petstore3.swagger.io web-page I press Authorize button and enter the value for the api_key.

  2. In Fiddler - Composer I choose POST method and https://petstore3.swagger.io/api/v3/pet address.

  3. In Header I set api_key value equal to the one I entered in step 1.

  4. In Body I copy-paste JSON from the example at petstore3.swagger.io

My request in a raw form looks ok:

POST https://petstore3.swagger.io/api/v3/pet HTTP/1.1
User-Agent:Fiddler Everywhere
Host:petstore3.swagger.io
Content-Length:215
api_key:20202020

{
  "id": 11,
  "name": "doggie2",
  "category": {
    "id": 1,
    "name": "Dogs"
  },
  "photoUrls": [
    "string"
  ],
  "tags": [
    {
      "id": 0,
      "name": "string"
    }
  ],
  "status": "available"
}

but when I execute it I get the 400 Bad Request error:

HTTP/1.1 400 Bad Request
Date: Mon, 07 Sep 2020 21:01:37 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Headers: Content-Type, api_key, Authorization
Access-Control-Expose-Headers: Content-Disposition
Server: Jetty(9.4.9.v20180320)
4
  • 3
    How about trying adding content-type: application/json ? – Michael Durrant Sep 7 '20 at 21:37
  • Try using postman, it's different enough to probably help you find the issue – Michael Durrant Sep 7 '20 at 23:47
  • Also, the server returns an explanation in body on error, something like { "code": 400, "message": "Input error: The input body..." }. That could also help you. But it seems it's really the missing header Content-Type in this case. – pavelsaman Sep 8 '20 at 7:44
  • Can you pass accept --> application/xml in the header. The response I am getting is in xml format and also the curl command generated swagger has the same. – Kshetra Mohan Prusty Sep 13 '20 at 14:06

Browse other questions tagged or ask your own question.