0

I am trying to post a file in wiremock and configure the file in mapping like below. And in the response I am seeing Content-Type, Content-Disposition etc, is there a way to disable this?

POST file

http://localhost:8080/__admin/files/some.json

used form-data to upload the file

contents of some.json

{
  "user": "xxx"
}

To create mapping

http://localhost:8080/__admin/mappings

{
    "request": {
        "method": "GET",
        "url": "/some"
    },
    "response": {
        "status": 200,
        "bodyFileName": "some.json",
                "headers": {
          "Content-Type": [
            "application/json;charset=UTF-8"
          ]
        }
    }
}

To check the api

http://localhost:8080/some

Response:

----------------------------228585284577179878202292
Content-Disposition: form-data; name="file"; filename="some.json"
Content-Type: application/json

{
  "user": "xxx"
}
----------------------------228585284577179878202292--

Like you see, there are additional content like below to the actual response. Wanted to disable the below. How to do this?

----------------------------228585284577179878202292
    Content-Disposition: form-data; name="file"; filename="some.json"
    Content-Type: application/json
    
----------------------------228585284577179878202292--  
Minisha
  • 2,117
  • 2
  • 25
  • 56

2 Answers2

0

Instead of form-data choose binary while uploading the file. Then it return only the actual response...

{
  "user": "xxx"
}
Minisha
  • 2,117
  • 2
  • 25
  • 56
0

If you put a file by HTTP request to wiremock instance, as @Minisha said, add 'Content-type': 'binary' header to your put request. Here is an example with python requests:


headers = {'Content-type': 'binary'}
requests.put(url=mock_wire_files_url_file_name, data=open(your_file, 'rb'), headers=headers)

superpen
  • 3
  • 2