Hi , I have an issue where i have two APIs,
API1 -> https://eprodservices-dev.devjcrinc.com/portal/api/Sites/GetSites?userId={{userID}}
body shows:
[
{
"siteId": 7911,
"siteName": "Abrazo Scottsdale Campus",
"hcoid": 9497,
"defaultSite": false
},
{
"siteId": 7771,
"siteName": "Baptist Health System",
"hcoid": 9209,
"defaultSite": false
},
{
"siteId": 7202,
"siteName": "BBH - PBMC, LLC",
"hcoid": 7934,
"defaultSite": false
},
{
"siteId": 7194,
"siteName": "BBH - SBMC, LLC",
"hcoid": 7924,
"defaultSite": false
},
{
"siteId": 7205,
"siteName": "BBH BMC, LLC",
"hcoid": 7938,
"defaultSite": false
},
{
"siteId": 7235,
"siteName": "BBH WBMC, LLC",
"hcoid": 7985,
"defaultSite": false
},
{
API2:{{domain}}/GetCommonInfo/GetUserSites?userId={{userID}}
Body shows -->
[
{
"SiteID": 685,
"HCOID": 2659,
"SiteName": "Saint Francis Hospital-Memphis",
"RoleID": 1,
"SiteFullName": "2659 Saint Francis Hospital-Memphis",
"IsAMPAccess": 1,
"IsTracersAccess": 1,
"SortOrder": 1
},
{
"SiteID": 697,
"HCOID": 2719,
"SiteName": "Doctors Medical Center of Modesto, Inc.",
"RoleID": 9,
"SiteFullName": "2719 Doctors Medical Center of Modesto, Inc.",
"IsAMPAccess": 1,
"IsTracersAccess": 1,
"SortOrder": 1
},
{
"SiteID": 760,
"HCOID": 2915,
"SiteName": "HDMC Holdings, L. L. C.",
"RoleID": 1,
"SiteFullName": "2915 HDMC Holdings, L. L. C.",
"IsAMPAccess": 1,
"IsTracersAccess": 1,
"SortOrder": 1
},
{
"SiteID": 1236,
"HCOID": 4831,
"SiteName": "TH Healthcare LTD",
"RoleID": 9,
"SiteFullName": "4831 TH Healthcare LTD",
"IsAMPAccess": 1,
"IsTracersAccess": 1,
"SortOrder": 1
},
{
"SiteID": 1255,
"HCOID": 4860,
"SiteName": "Twin Cities Community Hospital",
"RoleID": 9,
"SiteFullName": "4860 Twin Cities Community Hospital",
"IsAMPAccess": 1,
"IsTracersAccess": 1,
"SortOrder": 1
},
{
"SiteID": 1267,
"HCOID": 4877,
"SiteName": "Doctors Medical Center of Modesto",
"RoleID": 9,
"SiteFullName": "4877 Doctors Medical Center of Modesto",
"IsAMPAccess": 1,
"IsTracersAccess": 1,
"SortOrder": 1
},
I see the values in the bodies and format are different except for:
HCOID, SiteID, and SiteName âŚ
I basically want to extract the three elements from all the branches within the response body for API1 and I want to verify that API2 contains these same names and elements. (its not going to be in the same order)
I want this to be dynamic and not use hard coded values⌠since i want to add different userIDs through ⌠this same design for testing two site drop downs with multiple elements.
How can i go about doing this? ,
I did try this
pm.environment.set(âapi1â, pm.response.text());
it grabed all the data âŚ
and
in API 2 i did this :
pm.test(âshould have identical responses siteIdâ, () =>{
pm.response.to.have.body(JSON.parse(pm.environment.get('siteId')));
});
pm.test(âshould have identical responses siteNameâ, () =>{
pm.response.to.have.body(JSON.parse(pm.environment.get('siteName')));
});
pm.test(âshould have identical responses hcoidâ, () =>{
pm.response.to.have.body(JSON.parse(pm.environment.get('hcoid')));
});
pm.test(âshould have identical responses defaultSiteâ, () =>{
pm.response.to.have.body(JSON.parse(pm.environment.get('defaultSite')));
});
the API1 - grabs everything, i dont want that,
if i have 6 branches and 6 site IDs i want it to grab that, (also 6 hcoid, 6 sitenames, 6,default sites)
and then verify that those 6 display on API2âŚ
Please help,
Thanks