mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
How to pass attributes in JsonPath #375
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 @AndresGMD on GitHub (Oct 20, 2021).
Hello.
In this example I would like to get ID using Cleaning Path
I've defined my path like /path/* And I use the attribute request.PathSegments.1 to get the (*) value
How to pass this attribute in JsonPAth like this?
Thanks in Advance!
@StefH commented on GitHub (Oct 20, 2021):
Hello @andresendava ,
Did you try
request.PathSegments.2?@AndresGMD commented on GitHub (Oct 20, 2021):
Yes
@AndresGMD commented on GitHub (Oct 20, 2021):
I know that is attribute splitting path and I would like to use a clean path to pass parameters.
@StefH commented on GitHub (Oct 20, 2021):
Sorry, I don't understand what you want. Can you please provide a full example what you're trying to achieve?
@AndresGMD commented on GitHub (Oct 20, 2021):
Off course!!
I try to implemented a Get By ID using a clean Path
For example. In the request of my static file configuration I define the next Wildcardmatcher
I use PUT because I don know how to use Filters when I use BodyAsFile Instead (Issue #658) I use BodyAsJson for try this functionality. Let me show you my response.
In my response I would like to use {{request.PathSegments.1}} to get (asterisk) value of my path /json/* Example:
/json/1 => () = 1, /json/2 => () = 2, ... ,/json/n => (*) = n
And I need to use in my filter like this but actually it recognise like a text instead an attribute:
Thanks a lot Stef.
@StefH commented on GitHub (Oct 23, 2021):
Hello @andresendava,
I do understand your question.
However, this specific scenario is not supported (at least not in this form).
Because the HandleBars does not handle / replace two times. So that
request.PathSegments.1not not translated first.What you need to do is check the handlebars.net / handlebars.js documentation to see if you can write handlebars code which contains two parts: