Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return same request body #382

Closed
hsnsalhi opened this issue Nov 29, 2019 · 8 comments
Closed

Return same request body #382

hsnsalhi opened this issue Nov 29, 2019 · 8 comments
Labels

Comments

@hsnsalhi
Copy link

hsnsalhi commented Nov 29, 2019

Hello,
In the response.body I want to return the same request.body
For that I use the transformer but it transforms quotes too.
Here is an example:

{
  "Request": {
    "Path": {
      "Matchers": [
        {
          "Name": "WildcardMatcher",
          "Pattern": "/test"
        }
      ]
    },
    "Methods": [
      "post"
    ]
  },
  "Response": {
    "StatusCode": 300,
    
    "Body": "{{request.body}}",
    "UseTransformer": true
  }
}

When I test with

{
  "key":"value"
}

I get

{
  "key":"value"
}
@StefH
Copy link
Collaborator

StefH commented Nov 29, 2019

Can you try BodyAsJson?

@hsnsalhi
Copy link
Author

I get an exception

Providing a Response for Mapping 'fe1a2e88-e7a2-4404-a8c9-5186b42ec731' failed. HttpStatusCode set to 500. Exception: System.ArgumentException: Object serialized to String. JObject instance expected.

@StefH
Copy link
Collaborator

StefH commented Nov 30, 2019

1]
Use the triple-stash syntax: {{{request.body}}} --> Handlebars-Net/Handlebars.Net#55

2]
Try new preview NuGet: WireMock.Net.1.0.38-ci-12259.nupkg

@StefH
Copy link
Collaborator

StefH commented Dec 3, 2019

@hsnsalhi Can you try if this version solves your issue?

@StefH
Copy link
Collaborator

StefH commented Dec 6, 2019

@hsnsalhi Did you time to test this one?

@StefH
Copy link
Collaborator

StefH commented Dec 10, 2019

@hsnsalhi Can you please test?

1 similar comment
@StefH
Copy link
Collaborator

StefH commented Dec 17, 2019

@hsnsalhi Can you please test?

@StefH
Copy link
Collaborator

StefH commented Dec 26, 2019

PR merged to master.

@StefH StefH closed this as completed Dec 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants