Proxy request and modify response #490

Closed
opened 2025-12-29 15:25:07 +01:00 by adam · 2 comments
Owner

Originally created by @avrahamshurin on GitHub (Feb 21, 2023).

Originally assigned to: @StefH on GitHub.

Hi,
Is there any way to modify a response when running a server in proxy mode?
For example I got the following the response in proxy mode, and I need to change part of the body of the response before returning it:

{
	"Guid": "f43a630e-90a9-4b39-aa92-85820f84f4a7",
	"Title": "",
	"Request": {
		"Path": {
			"Matchers": [
				{
					"Name": "WildcardMatcher",
					"Pattern": "/Abc",
					"IgnoreCase": false
				}
			]
		},
		"Methods": [
			"GET"
		]
	},
	"Response": {
		"StatusCode": 200,
		"Body": "{\"revision\":\"2023-01-18T17:56:59.5680265Z\",\"json\":\"{\\\"URL\\\":\\\"https://www.google.com/abc\\\"}\"}",
		"Headers": {
			"Content-Type": "application/json; charset=utf-8"
		}
	}
}

and I want to change the url in the response body to:

"https://localhost:8080/abc"
Originally created by @avrahamshurin on GitHub (Feb 21, 2023). Originally assigned to: @StefH on GitHub. Hi, Is there any way to modify a response when running a server in proxy mode? For example I got the following the response in proxy mode, and I need to change part of the body of the response before returning it: ``` json { "Guid": "f43a630e-90a9-4b39-aa92-85820f84f4a7", "Title": "", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/Abc", "IgnoreCase": false } ] }, "Methods": [ "GET" ] }, "Response": { "StatusCode": 200, "Body": "{\"revision\":\"2023-01-18T17:56:59.5680265Z\",\"json\":\"{\\\"URL\\\":\\\"https://www.google.com/abc\\\"}\"}", "Headers": { "Content-Type": "application/json; charset=utf-8" } } } ``` and I want to change the url in the response body to: ``` "https://localhost:8080/abc" ```
adam added the question label 2025-12-29 15:25:07 +01:00
adam closed this issue 2025-12-29 15:25:08 +01:00
Author
Owner

@StefH commented on GitHub (May 12, 2023):

@avrahamshurin
I don't think so, but I'll check this.

@StefH commented on GitHub (May 12, 2023): @avrahamshurin I don't think so, but I'll check this.
Author
Owner

@StefH commented on GitHub (May 31, 2023):

@avrahamshurin
This can be done using response templating :
https://github.com/WireMock-Net/WireMock.Net/wiki/Response-Templating

@StefH commented on GitHub (May 31, 2023): @avrahamshurin This can be done using response templating : https://github.com/WireMock-Net/WireMock.Net/wiki/Response-Templating
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#490