I am verifying the data within the JSON, but I am unable to get the results I needed from the sample snippets. I am new to this and try everything possible. Below is my JSON file.
[
{
"type": "Concept",
"uuid": "5e6c06d89c3b78004bbb66bb",
"id": "pKM2shbjfwR",
"external_id": "pKM2shbjfwR",
"concept_class": "Data Element",
"datatype": "Numeric",
"display_name": "HTS_INDEX (N, TA, Age Aggregated/Sex/Contacts): Number of contacts",
"display_locale": "en",
"names": [
{
"uuid": "1ee5000da0ca49d79637c976d6987d5c",
"external_id": null,
"name": "HTS_INDEX (N, TA, Age Aggregated/Sex/Contacts): Number of contacts",
"locale": "en",
"locale_preferred": true,
"name_type": "Fully Specified",
"type": "ConceptName"
}
]
The code below verify the data matches with the JSON file, but when have the type in the CSV file with the additional values like HTS_INDEX and concept_class Data Element then I am trying to figure out to capture the values from CSV and verify with the JSON file.
var jsonData = pm.response.json();
pm.test(“Verify source”, function() {
pm.expect(jsonData.type).is.to.equal(Concept);
Are you using a CSV or a JSON file to store the data? You’ve mentioned both here so I just wanted to clarify. How are you currently referencing the values from the file, in the requests?
What does the response body look like? Is it the same structure as the data file?
To get specific values from the data file you can use pm.iterationData.get("var_name") - var_name here would match to the key in the JSON file or column in the CSV file.
I have the data in the CSV file, I am not storing any data. I have to verify the values in the CSV against the JSON in the API url. Based on the JSON below, the CSV file will have the following: I will take HTS_INDEX, Concept to verify that these values are in the API. The code works without the CSV file to verify the JSON.