Extract value from json field when using custom Content-Type #792
-
Hi, The application I'm trying to mock is using a custom Content-Type, albeit still in json form, but the Content-Type being passed to the mock (and real application) doesn't conform to application/json An example POST request body: Now I want to be able to capture the productId from the request as this is needed in the response. Is there a way using a regex to extract this value? I know by switching over to a supported Content-Type such as application/json that I can use I've tried using the stringify helper but this didn't work. I've also tried to replicate the example given in the documentation HERE but that didn't work either. Really appreciate any help with this. Many thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Did you maybe try with substr and indexof ? |
Beta Was this translation helpful? Give feedback.
-
@255kb suggestion (above) of using the proxy feature of mockoon to adjust the content-type allowed me to make use of the body helper, so I was able to fetch the desired value from the request and reuse in the payload. |
Beta Was this translation helpful? Give feedback.
@255kb suggestion (above) of using the proxy feature of mockoon to adjust the content-type allowed me to make use of the body helper, so I was able to fetch the desired value from the request and reuse in the payload.