Forum Discussion

Frido's avatar
Frido
New Contributor
7 years ago
Solved

How to create a JSONPath Property Transfer including a ${Properties#property} ?

In my project I want to use the test step Property Transfer to pass along some values from a REST response with JSON data within it. The JSONPath I want makes use of a property from a Properties Step called TestData.

 

The (part of the) data looks like this:

{
	"model": {
		"key": "P394-C0-C0-C0-C0-C0-C0-F0",
		"functionalKey": "P394_Melding-Organisatie_1",
		"name": "Melding.Organisatie",
		"properties": {
			
		},
		"questionText": "Organisatie",
		"explainText": null,
		"dataType": "entity",
		"rejectedValue": null,
		"readonly": true,
		"required": true,
		"hasDomain": true,
		"multiValued": false,
		"refresh": false,
		"displayLength": -1,
		"domain": [{
			"displayValue": "Amsterdam",
			"value": "Organisatie|0f7d20b8-ea98-412e-b375-b51b5d2aa131|"
		},
		{
			"displayValue": "Stockholm",
			"value": "Organisatie|fdea2088-60f9-4064-81b2-f491bc0d5b58|"
		},
		{
			"displayValue": "Luxembourg",
			"value": "Organisatie|fdbf6753-f727-47c5-b5e2-9ed32c99bd2c|"
		},
		{
			"displayValue": "Paris",
			"value": "Organisatie|b26c12a1-794a-472c-adec-d8240cd14770|"
		}],
		"messages": [],
		"values": ["Organisatie|b26c12a1-794a-472c-adec-d8240cd14770|"],
		"validations": [{
			"blocking": true,
			"type": "Required",
			"message": null,
			"parameters": {
				
			}
		}],
		"type": "field",
		"styles": []
	}
}

The JSONPath string looks like this:

$..model.domain[?(@.displayValue=='${TestData#Gegevens_melder.Organisatie}')].value[0]

 

When I use this JSONPath within a property transfer, the value of ${TestData#Gegevens_melder.Organisatie} cannot be found properly. I have verified the JSONPath by adding a JSONPath Match assertion to the specific RestRequest step. Within this assertion the JSONPath works fine so I may conclude the path is correct.

 

How can I create such a Property Transfer?

I don't want to use the ResponseAsXml possibility because of the enormous namespace I have to declare... but using that posibility works fine when I use the XPath 

//m:displayValue[text()='${TestData#Gegevens_melder.Organisatie}']/../m:value

3 Replies