mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
Combine a value from query with string data in WithBodyAsJson #482
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mattisking on GitHub (Jan 19, 2023).
Originally assigned to: @StefH on GitHub.
I'm trying something which I'm sure is simple but I can't seem to get working. Basically I want to take a value from the query and echo it back inside a json object, but with some additional hardcoded information included. Here's the example I'm working with:
(yes, I'm mocking an OAuth call)
An example URL:
https://localhost:7012/oauth2/v1/token?grant_type=client_credentials&scope=scope1 scope2 scope3
I'd like to get back something like:
My " helloworld" is ignored, I suspect it's dropped in the transformer.
@StefH commented on GitHub (Jan 19, 2023):
@mattisking
The solution is to use
String.AppendandString.Join.Example:
@mattisking commented on GitHub (Jan 20, 2023):
Thanks! Is there a section of the help that digs into the available options:
"{{String.Append (String.Join request.query.scope) " helloworld" }}"
String.Append
String.Join
@StefH commented on GitHub (Jan 20, 2023):
These methods are extensions to Handlebars.Net:
See https://github.com/Handlebars-Net/Handlebars.Net.Helpers/wiki/String