Hi Team, I am starting to use the Record feature. ...
# help
j
Hi Team, I am starting to use the Record feature. I am trying to capture the response for
<https://jsonplaceholdfollowsicode.com/todos/1>
.
• I launch the
start
as folows:
Copy code
POST <http://localhost:8080/__admin/recordings/start>
Content-Type: application/json

{
  "targetBaseUrl" : "<https://jsonplaceholder.typicode.com>",
  "captureHeaders" : {
    "Accept" : { },
    "Content-Type" : {
      "caseInsensitive" : true
    }
  },
  "requestBodyPattern" : {
    "matcher" : "equalToJson",
    "ignoreArrayOrder" : false,
    "ignoreExtraElements" : true
  },
  "persist" : false,
  "repeatsAsScenarios" : false,
  "transformers" : [ "modify-response-header" ],
  "transformerParameters" : {
    "headerValue" : "123"
  }
}
• Then, I try to get the
todo
detail with:
Copy code
GET <http://localhost:8080/todos/1> (proxy with the targetUrl)
• Finally, launch the
stop
: `
Copy code
POST <http://localhost:8080/__admin/recordings/stop>
I receive the following:
Copy code
{
  "mappings": [
    {
      "id": "5775bb25-7063-4990-b198-6e08d2473408",
      "name": "todos_1",
      "request": {
        "url": "/todos/1",
        "method": "GET",
        "headers": {
          "Accept": {
            "equalTo": "*/*"
          }
        }
      },
      "response": {
        "status": 200,
        "body": "�� ���%�WV\rm%\n:�˫�y�ȁ[�P۝߁��>��w9s\b�èS7���˻�늇>qs*��\f�",
        "headers": {
          "CF-RAY": "870117011b83867e-MAD",
          "Server": "cloudflare",
          "X-Ratelimit-Remaining": "999",
          "X-Content-Type-Options": "nosniff",
          "Pragma": "no-cache",
          "Reporting-Endpoints": "heroku-nel=<https://nel.heroku.com/reports?ts=1711146555&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=%2ByQQY5%2FiCGMIRgu2T4yZyl6O7Od6LelxVF5Ou5BCbO0%3D>",
          "Date": "Sat, 06 Apr 2024 10:28:13 GMT",
          "Via": "1.1 vegur",
          "X-Ratelimit-Reset": "1711146598",
          "X-Ratelimit-Limit": "1000",
          "CF-Cache-Status": "HIT",
          "Etag": "W/\"53-hfEnumeNh6YirfjyjaujcOPPT+s\"",
          "Cache-Control": "max-age=43200",
          "Nel": "{\"report_to\":\"heroku-nel\",\"max_age\":3600,\"success_fraction\":0.005,\"failure_fraction\":0.05,\"response_headers\":[\"Via\"]}",
          "Access-Control-Allow-Credentials": "true",
          "Report-To": "{\"group\":\"heroku-nel\",\"max_age\":3600,\"endpoints\":[{\"url\":\"<https://nel.heroku.com/reports?ts=1711146555&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=%2ByQQY5%2FiCGMIRgu2T4yZyl6O7Od6LelxVF5Ou5BCbO0%3D>\"}]}",
          "Vary": "Origin, Accept-Encoding",
          "Expires": "-1",
          "alt-svc": "h3=\":443\"; ma=86400",
          "Age": "18342",
          "X-Powered-By": "Express",
          "Content-Type": [
            "application/json; charset=utf-8",
            "application/json"
          ]
        }
      },
      "uuid": "5775bb25-7063-4990-b198-6e08d2473408"
    }
  ]
}
The
body
value is
Copy code
"body": "�� ���%�WV\rm%\n:�˫�y�ȁ[�P۝߁��>��w9s\b�èS7���˻�늇>qs*��\f�",
Is it possible to get the body with json format u through the
jsonBody
value?
l
When I hit the
/todos/1
endpoint directly I get a
content-encoding: br
header back. This means the response is encoded using the Brotli algorithm. I guess WireMock doesn't understand this response encoding which is why you are seeing the garbage in the body element. If I make the request to the endpoint with the
Accept-Encoding: identity
header then I no longer see the
content-encoding: br
header coming back.
identity
means no compression. Try recording a request with the
Accept-Encoding: identity
header and see if that helps.
🙌 1
j
Thanks for the help 😊
l
No worries.