[Question] How to match GET with body? #623

Closed
opened 2025-12-29 08:31:22 +01:00 by adam · 2 comments
Owner

Originally created by @vovka15 on GitHub (Aug 9, 2024).

Hello.
How to match a GET request with a body?
Yes, it's bad that GET uses body, but we can't do nothing about it.

So when I send GET request with a body Wiremock logs that body is null.

      Admin[False] {
        "Guid": "7040ab40-3a4d-45ec-9838-3c1e928ed8f4",
        "Request": {
          "ClientIP": "hidden",
          "DateTime": hidden",
          "Path": "/",
          "AbsolutePath": "/",
          "Url": "hidden",
          "AbsoluteUrl": "hidden",
          "ProxyUrl": null,
          "Query": {},
          "Method": "GET",
          "HttpVersion": "1.1",
          "Headers": {
            "Cache-Control": [
              "no-cache"
            ],
            "Connection": [
              "keep-alive"
            ],
            "Content-Type": [
              "application/json"
            ],
            "Accept": [
              "*/*"
            ],
            "Accept-Encoding": [
              "gzip, deflate, br"
            ],
            "Host": [
              "hidden"
            ],
            "User-Agent": [
              "PostmanRuntime/7.41.0"
            ],
            "Content-Length": [
              "106"
            ],
            "Postman-Token": [
              "hidden"
            ]
 
          },
          "Cookies": {},
          "Body": null,
          "BodyAsJson": null,
          "BodyAsBytes": null,
          "BodyEncoding": null,
          "DetectedBodyType": null,
          "DetectedBodyTypeFromContentType": null
        },
        "Response": {
          "StatusCode": 404,
          "Headers": {
            "Content-Type": [
              "application/json"
            ]
 
          },
          "BodyDestination": null,
          **"Body": null,**
          "BodyAsJson": {
            "Guid": null,
            "Status": "No matching mapping found",
            "Error": null
 
          },
          "BodyAsBytes": null,
          "BodyAsFile": null,
          "BodyAsFileIsCached": null,
          "BodyOriginal": null,
          "BodyEncoding": null,
          "DetectedBodyType": 2,
          "DetectedBodyTypeFromContentType": null,
          "FaultType": null,
          "FaultPercentage": null
        },
        "MappingGuid": null,
        "MappingTitle": null,
        "RequestMatchResult": null,
        "PartialMappingGuid": "2301bc13-4b21-4faf-8d86-b92e79ea85d2",
        "PartialMappingTitle": null,
        "PartialRequestMatchResult": {
          "TotalScore": 2.0,
          "TotalNumber": 3,
          "IsPerfectMatch": false,
          "AverageTotalScore": 0.6666666666666666,
          "MatchDetails": [
            {
              "Name": "PathMatcher",
              "Score": 1.0
            },
            {
              "Name": "MethodMatcher",
              "Score": 1.0
            },
            {
              "Name": "BodyMatcher",
              "Score": 0.0
            }
          ]
}

Is it possible to match GET request with a body?
Thanks in advance.

PS: I am using latest WireMock version.

Originally created by @vovka15 on GitHub (Aug 9, 2024). Hello. How to match a GET request with a body? Yes, it's bad that GET uses body, but we can't do nothing about it. So when I send GET request with a body Wiremock logs that body is **null**. ```c# Admin[False] { "Guid": "7040ab40-3a4d-45ec-9838-3c1e928ed8f4", "Request": { "ClientIP": "hidden", "DateTime": hidden", "Path": "/", "AbsolutePath": "/", "Url": "hidden", "AbsoluteUrl": "hidden", "ProxyUrl": null, "Query": {}, "Method": "GET", "HttpVersion": "1.1", "Headers": { "Cache-Control": [ "no-cache" ], "Connection": [ "keep-alive" ], "Content-Type": [ "application/json" ], "Accept": [ "*/*" ], "Accept-Encoding": [ "gzip, deflate, br" ], "Host": [ "hidden" ], "User-Agent": [ "PostmanRuntime/7.41.0" ], "Content-Length": [ "106" ], "Postman-Token": [ "hidden" ] }, "Cookies": {}, "Body": null, "BodyAsJson": null, "BodyAsBytes": null, "BodyEncoding": null, "DetectedBodyType": null, "DetectedBodyTypeFromContentType": null }, "Response": { "StatusCode": 404, "Headers": { "Content-Type": [ "application/json" ] }, "BodyDestination": null, **"Body": null,** "BodyAsJson": { "Guid": null, "Status": "No matching mapping found", "Error": null }, "BodyAsBytes": null, "BodyAsFile": null, "BodyAsFileIsCached": null, "BodyOriginal": null, "BodyEncoding": null, "DetectedBodyType": 2, "DetectedBodyTypeFromContentType": null, "FaultType": null, "FaultPercentage": null }, "MappingGuid": null, "MappingTitle": null, "RequestMatchResult": null, "PartialMappingGuid": "2301bc13-4b21-4faf-8d86-b92e79ea85d2", "PartialMappingTitle": null, "PartialRequestMatchResult": { "TotalScore": 2.0, "TotalNumber": 3, "IsPerfectMatch": false, "AverageTotalScore": 0.6666666666666666, "MatchDetails": [ { "Name": "PathMatcher", "Score": 1.0 }, { "Name": "MethodMatcher", "Score": 1.0 }, { "Name": "BodyMatcher", "Score": 0.0 } ] } ``` Is it possible to match GET request with a body? Thanks in advance. PS: I am using latest WireMock version.
adam added the question label 2025-12-29 08:31:22 +01:00
adam closed this issue 2025-12-29 08:31:22 +01:00
Author
Owner

@StefH commented on GitHub (Aug 9, 2024):

Set AllowBodyForAllHttpMethods to true in the settings.

@StefH commented on GitHub (Aug 9, 2024): Set **AllowBodyForAllHttpMethods** to true in the settings.
Author
Owner

@vovka15 commented on GitHub (Aug 9, 2024):

It worked! Thank you

@vovka15 commented on GitHub (Aug 9, 2024): It worked! Thank you
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#623