Getting a value of a collection

Hello I am trying to get a value of a collection value. Here is a sample of the Body of the POST request.

    "SRDefinitionName": "Associated People",
    "SRGuid": "b45d8ac0-081a-4e23-9ab6-82378a7a9658",
    "ParentId": 771626,
    "CaseId": null,
    **"Status": "Not Submitted",**
    "CurrentWorkflowTask": null,
    "RequestorId": "000022803",
    "Requestor": "Bryan Kruep",
    "CreateDate": "2021-05-14T09:22:28.567-05:00",
    "DueDate": "2021-05-19T09:52:00-05:00",
    "Generic2": "",
    "Generic3": "",
    "Generic4": "",
    "Generic5": "",
    "Generic6": "",
    "Generic7": "",
    "Generic8": "",
    "Generic9": "",
    "Generc10": "",
    "Generic11": "",
    "Generic12": "",
    "Generic13": "",
    "Geneic14": "",
    "Generic15": "",
    "GenericNumber": 0.0,
    "Amount": 0.0,
    "Customer": "60599286",
    "Quantity": 0.0,
    "RepCode": "TK04",
    "AuditText": "",
    "State": {
        "Module": "Main",
        "Page": "Entry",
        "Index": 0,
        "CurrentPageId": null,
        "NextPageId": null
    "Messages": [],
    "Collections": [
            "Name": "Main",
            "Type": "Module",
            "Rows": [
                    "RowKey": "0",
                    "AssociatedPeople_DOCALastRefreshed": "5/14/2021 9:22:29 AM",
                    "AssociatedPeople_ExistingTPAPOA": false,
                    "AssociatedPeople_TotalAddressOverride": 0,
                    "AssociatedPeople_TotalAssociatedPeople": 0,
                    "AssociatedPeople_TotalFINRARelChild": 0,
                    "AssociatedPeople_TotalFINRARelSelf": 0,
                    "AssociatedPeople_TotalFINRARelSpouse": 0,
                    "AssociatedPeople_TotalPowerOfAttorneys": 0,
                    "AssociatedPeople_TotalThirdPartyAuth": 0,
                    "Balance_TotalAccountBalance": -1000.0,
                    **"ClientAccount_Category": "7",**
                    "CustomerSuitability_LastStatementDate": "2104",
                    "CustomerSuitability_MaskedSSN": "XXXXX0489",
                    "CustomerSuitability_RiskTolerance": "5",
                    "ManagedAccount_InvestmentObjective": "B"

When I try running this test below I get an error that the value is not defined. Verified this with a console log. I can get the “Status” variable to return a value but not the ClientAccount_Category value. I know it has something to do with the pm.expect(jsonData) part but not sure how to set this correctly. Any help would be greatly appreciated:

Hi @bkruep,

The reason that Status is working but ClientAccount_Category isn’t, is that the latter is nested slightly deeper within your JSON response.

On this occasion, the value that you need is (I think):


The [0] indicators are needed because both the Collections and Rows in your JSON structure are capable of containing multiple items; this tells the code that you want to use the first item in each section (indexes start from 0). So you may want to bear in mind what you would want to select if you received multiple items in your response.

1 Like

Hi @neilstudd

Thanks for the help. That is exactly what I wanted it to do. One less thing I need to figure out.