title: How to take value from JSON response body and set it as an environment variable in Postman
body: <p>While hitting the service in Postman I am getting the multiple blocks in response body, i need to take one element value and need to store it in Environment variable to use it in next request.</p>
  
  <p>Kindly help to take the value of <code>depositInfoId</code> and need to set in Environment variable.</p>
  
  <p>I have tried with below one but not worked.<br></p>
  
  <pre><code>pm.environment.set("depositInfoId",pm.response.json().depositInfoList);
  pm.environment.set("depositInfoId",pm.response.json().depositInfoList.depositInfoId);
  </code></pre>
  
  <p>Below is the sample Response body with few blocks:</p>
  
  <pre><code>{
      "qualStatus": "PASS",
      "blackList": {
          "blackListStatus": "PASS",
          "blackListStatusDesc": "CustomerName Match Not Found."
      },
      "fraudCheck": {
          "linesActivated": null,
          "status": "NA",
          "activationDetails": null,
          "errorDetails": null,
          "creditCheck": {
              "intlDialingEligibilityIndicator": true,
              "intlRoamingEligibilityIndicator": true,
              "creditCheckDetails": [{
                  "linesApproved": 1,
                  "approvedTerm": "24",
                  "accountSpendingLimit": null,
                  "lineDepositAmount": null,
                  "securityDepositeAvailableIndicator": null,
                  "creditLimitProgramIndicator": null,
                  "noDeviceProgramIndicator": null,
                  "creditOptionId": null
              }],
              "status": "APPROVED",
              "errorDetails": null,
              "accountNumber": "12345678",
              "creditAssessmentID": "123456",
              "contractTypes": null,
              "esimProductCode": null
          }
      },
      "depositInfoList": [{
          "depositInfoId": 863,
          "transactionID": "123456",
          "lineDepositAmount": null,
          "linesActivated": "1",
          "internationalDailingDeposit": null,
          "approvedTerm": "24",
          "depositSubscriberCount": null,
          "spendingLimit": null,
          "creditAssessmentId": "123456",
          "securityDepositAvailable": null,
          "creditLimitIndicator": null,
          "noDeviceProgramIndicator": null,
          "creditOptionId": null
      }]
  }
  </code></pre>
  
  <p>In Environment variable values stored as below when I use first code.
  <code>depositInfoId - [object Object] - [object Object]</code></p>
  
  <p>When I use second code fields are blank not stored in it.</p>