Assign Variable in Request Body (Canned JSON File) #366

Closed
opened 2025-12-29 15:21:55 +01:00 by adam · 9 comments
Owner

Originally created by @devmariodiaz on GitHub (Oct 7, 2021).

Hello Stef,

I hope everything is doing well.

Could you please let me know if there is a way to replace "Pattern" parameter in post request with a filename i.e "request.xml" or variable?
I really appreciate it
i.e "PatternAsFile": "requestbody.xml" such as Request Templating.

SOAPconfiguration.json.zip

Originally created by @devmariodiaz on GitHub (Oct 7, 2021). Hello Stef, I hope everything is doing well. Could you please let me know if there is a way to replace "Pattern" parameter in post request with a filename i.e "request.xml" or variable? I really appreciate it i.e "PatternAsFile": "requestbody.xml" such as Request Templating. [SOAPconfiguration.json.zip](https://github.com/WireMock-Net/WireMock.Net/files/7306987/SOAPconfiguration.json.zip)
adam added the question label 2025-12-29 15:21:55 +01:00
adam closed this issue 2025-12-29 15:21:55 +01:00
Author
Owner

@StefH commented on GitHub (Oct 8, 2021):

Hello Mario.
This is not yet implemented.

This can be done like you propose:

"Body": {
  "Matcher": {
	"Name": "ExactMatcher",
	"PatternAsFile": "requestbody.xml"
  }
}

Another option would be:

"Body": {
  "Matcher": {
	"Name": "ExactMatcher",
	"Pattern": {
              "WithFile": "requestbody.xml",
              "FromFile": "requestbody.xml",
              "UsingFile": "requestbody.xml",
        }
  }
}
@StefH commented on GitHub (Oct 8, 2021): Hello Mario. This is not yet implemented. This can be done like you propose: ``` js "Body": { "Matcher": { "Name": "ExactMatcher", "PatternAsFile": "requestbody.xml" } } ``` Another option would be: ``` js "Body": { "Matcher": { "Name": "ExactMatcher", "Pattern": { "WithFile": "requestbody.xml", "FromFile": "requestbody.xml", "UsingFile": "requestbody.xml", } } } ```
Author
Owner

@StefH commented on GitHub (Oct 9, 2021):

Hello @devmariodiaz,

I think that "PatternAsFile": "requestbody.xml" is the most logical option. Do you agree?

@StefH commented on GitHub (Oct 9, 2021): Hello @devmariodiaz, I think that `"PatternAsFile": "requestbody.xml"` is the most logical option. Do you agree?
Author
Owner

@devmariodiaz commented on GitHub (Oct 11, 2021):

Thanks, Stef for your dedicated time.

I'll test this great solution

@devmariodiaz commented on GitHub (Oct 11, 2021): Thanks, Stef for your dedicated time. I'll test this great solution
Author
Owner

@StefH commented on GitHub (Oct 11, 2021):

(Note that PatternAsFile is not yet implemented, so you cannot test that)

@StefH commented on GitHub (Oct 11, 2021): (Note that PatternAsFile is not yet implemented, so you cannot test that)
Author
Owner

@devmariodiaz commented on GitHub (Oct 11, 2021):

I got it 👍

@devmariodiaz commented on GitHub (Oct 11, 2021): I got it 👍
Author
Owner

@StefH commented on GitHub (Oct 12, 2021):

https://github.com/WireMock-Net/WireMock.Net/pull/651

@StefH commented on GitHub (Oct 12, 2021): https://github.com/WireMock-Net/WireMock.Net/pull/651
Author
Owner

@StefH commented on GitHub (Oct 12, 2021):

Hello @devmariodiaz ,

I've created a preview version 1.4.23-ci-15479 which should implement this.

For info on preview versions ; see https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

@StefH commented on GitHub (Oct 12, 2021): Hello @devmariodiaz , I've created a preview version `1.4.23-ci-15479` which should implement this. For info on preview versions ; see https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
Author
Owner

@devmariodiaz commented on GitHub (Oct 15, 2021):

Hello Stef,

I was testing this solution and it's working fine, would you please incorporate this feature in the next version.

Thanks a lot for your time.

@devmariodiaz commented on GitHub (Oct 15, 2021): Hello Stef, I was testing this solution and it's working fine, would you please incorporate this feature in the next version. Thanks a lot for your time.
Author
Owner

@StefH commented on GitHub (Oct 15, 2021):

Hello Mario,
Thanks for testing, I'll merge this code.

@StefH commented on GitHub (Oct 15, 2021): Hello Mario, Thanks for testing, I'll merge this code.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#366