Slackbot
01/28/2024, 3:01 AMTom
01/29/2024, 11:45 AM{
"name": "Match accounts with with 8",
"request": {
"urlPath": "/accounts",
"method": "GET",
"headers": {
"personaldetails": {
"matchesJsonPath": {
"expression": "$.account",
"matches": "8.*"
}
}
}
},
"response": {
"status": 200,
"body": "1st response"
},
"priority": 4
}
and a generic one to match anything else:
{
"name": "Match any other account",
"request": {
"urlPath": "/accounts",
"method": "GET"
},
"response": {
"status": 200,
"body": "2nd response"
}
}
Sai Kiran
01/29/2024, 4:36 PMTom
01/29/2024, 4:45 PMx-my-header
. You can modify the first stub as follows:
{
"name": "Match accounts with with 8",
"request": {
"urlPath": "/accounts",
"method": "GET",
"headers": {
"x-my-header": {
"matchesJsonPath": {
"expression": "$.personalDetails.account.accountNo",
"matches": "8.*"
}
}
}
},
"response": {
"status": 200,
"body": "1st response"
},
"priority": 4
}
Sai Kiran
01/29/2024, 10:10 PMTom
01/30/2024, 10:26 AMSai Kiran
01/30/2024, 2:39 PMTom
01/30/2024, 3:32 PM{
"personalDetails": {
"account": {
"accountNo": [
"88000000"
],
"firstName": "x",
"lastName": "bradshaw"
}
}
}
with this stub:
{
"name": "Match accounts with with 8",
"request": {
"urlPath": "/accounts",
"method": "GET",
"headers": {
"x-my-header": {
"matchesJsonPath": {
"expression": "$.personalDetails.account.accountNo[0]",
"matches": "8.*"
}
}
}
},
"response": {
"status": 200,
"body": "1st response"
},
"priority": 4
}
Sai Kiran
01/30/2024, 3:49 PMSai Kiran
01/30/2024, 4:19 PM{
"personalDetails": {
"account": {
"accountNo": [
"88000000"
],
"firstName": "x",
"lastName": "bradshaw"
}
}
}
another question , can i copy the value of accountNo i.e 88000000 to a field in bodyFileName.json (under mappings) ?
i did use transformer and wrote a custom method deserializing and serializing using Gson jackson libraries. is that necessary ? is there much simpler way to copy that value from input request to stub and return stub ?Tom
01/30/2024, 6:12 PMTom
01/30/2024, 6:12 PM{{jsonPath request.body 'personalDetails.account.accountNo[0]'}}
Tom
01/30/2024, 6:13 PMresponse-template
transformer on the stub)Sai Kiran
02/20/2024, 5:29 AM{
"name": "Match accounts with with 8",
"request": {
"urlPath": "/accounts",
"method": "GET",
"headers": {
"x-my-header": {
"matchesJsonPath": {
"expression": "$.personalDetails.account.accountNo[0]",
"matches": "8.*"
}
}
}
},
"response": {
"status": 200,
"bodyfilename": "result.json"
},
"priority": 4
}
inside result.json, i should mention this like below
{
number_n: {{jsonPath request.headersx-my-header '$.personalDetails.account.accountNo[0]'}}
}
is this right ?Tom
02/20/2024, 11:24 AMresponse
:
"transformers": ["response-template"],
Your jsonPath helper is also missing a . after headers
Sai Kiran
02/20/2024, 3:12 PM{
"personalDetails": {
"account": {
"accountNo": [
"88000000"
],
"firstName": "x",
"lastName": "bradshaw"
}
}
}
In result.json i used these lines
{
number_n: {{jsonPath request.headers.x-my-header '$.personalDetails.account.accountNo[0]'}}
}
Tom
02/20/2024, 3:45 PM{
number_n: {{jsonPath request.headers.x-my-header.0 '$.personalDetails.account.accountNo[0]'}}
}