# Variables are not substituted in the Performance run from uploaded data.json , while working correctly in functional run

**URL:** <https://community.postman.com/t/variables-are-not-substituted-in-the-performance-run-from-uploaded-data-json-while-working-correctly-in-functional-run/82756>\
**Category:** Help Hub\
**Tags:** variables, performance\
**Created:** [July 23, 2025, 5:20pm UTC](https://community.postman.com/t/variables-are-not-substituted-in-the-performance-run-from-uploaded-data-json-while-working-correctly-in-functional-run/82756 "2025-07-23T17:20:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![IrinaG1](https://avatars.discourse-cdn.com/v4/letter/i/e9c0ed/32.png) [@IrinaG1](https://community.postman.com/u/IrinaG1)\
**Post date:** [July 23, 2025, 5:20pm UTC](https://community.postman.com/t/variables-are-not-substituted-in-the-performance-run-from-uploaded-data-json-while-working-correctly-in-functional-run/82756/1 "2025-07-23T17:20:18Z")

</div>

Hi ,  
I have a collection for performance testing , it reads data from the input data.json file , should be pretty much straight forward and works correctly in functional run , but when run performance test , variables values are not substituted .  
Data in json looks like :

```auto
let initialData = 
    [
        {
            clientId:"",
            tenant:"",
            agents:[
                {
                agent_id:"",
                agent_token:""
                },
                {
                agent_id:"",
                agent_token:""
                },
                {
                agent_id:"",
                agent_token:""
                },
                {
                agent_id:"",
                agent_token:""
                },
                {
                agent_id:"",
                agent_token:""
                },
                {
                agent_id:"",
                agent_token:""
                },
                {
                agent_id:"",
                agent_token:""
                },
                {
                agent_id:"",
                agent_token:""
                },
                {
                agent_id:"",
                agent_token:""
                },
                {
                agent_id:"",
                agent_token:""
                }
            ],
            list:"",
            assets:[{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},
            {asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""},{asset_id:"",ip:""}],
            policies:[],
            rules:[],

        }]

```

In each request in the collection we fetch data in pre-requisite scripts with code

```auto
var stringAgents = JSON.stringify(pm.iterationData.get("agents"));
var agents = JSON.parse(stringAgents);
var agent_token = agents[0].agent_token;
pm.collectionVariables.set("agent_token", agent_token);
var stringAssets = JSON.stringify(pm.iterationData.get("assets"));
var assets = JSON.parse(stringAssets);
var asset_id = assets[0].asset_id;
console.log("asset_id:" + asset_id)
pm.collectionVariables.set("asset_id", asset_id);
var ip = assets[0].ip;
console.log("ip:" +ip)
pm.collectionVariables.set("ip", ip);
var tenant = pm.iterationData.get("tenant");
console.log("tenant:" +tenant)
pm.collectionVariables.set("tenant", tenant);
var list = pm.iterationData.get("list");
console.log("list"+list)
pm.collectionVariables.set("list", list);

```

But every time when I run performance test , with data.json , 20 UV users with rump up period , I got 100% fails because variables that are expected in the request headers and authentication are not substituted

 ![Screenshot 2025-07-23 at 20.17.33](https://us1.discourse-cdn.com/getpostman/original/3X/f/a/fa581bc2d4aa0058514ddb3b18707cb47a5fe276.png)  
While when functional run with same data.json file , all data is substituted correctly  
 ![Screenshot 2025-07-23 at 20.19.50](https://us1.discourse-cdn.com/getpostman/original/3X/6/6/6684f18fffb8241c09eb7c960837a9c248f1d573.png)  
Please advise what am i doing wrong

---

<div class="post-metadata">

**Author:** ![yonandualem](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/yonandualem/32/33147_2.png) [@yonandualem](https://community.postman.com/u/yonandualem)\
**Post date:** [July 24, 2025, 6:33am UTC](https://community.postman.com/t/variables-are-not-substituted-in-the-performance-run-from-uploaded-data-json-while-working-correctly-in-functional-run/82756/2 "2025-07-24T06:33:06Z")

</div>

Try this fixes

1. Instead of setting collection variables, reference `pm.iterationData` directly in your request builder (URL, Headers, Body).  
**Example:** If your request needs `{{agent_token}}` , change it to use `{{$iterationData.agent_token}}` or construct it in the pre-request script as an environment variable.

2. Use `pm.environment.set("agent_token", agent_token)` instead of collection variables.  
**Note:** Environment variables are better scoped for VU runs than collection variables.

3. If possible, flatten your data.json so each row (object) contains all the variables needed for one iteration/VU. This avoids the need for dynamic variable-setting in scripts.

```auto
var agents = pm.iterationData.get("agents");
var agent_token = agents[0].agent_token;
pm.environment.set("agent_token", agent_token);

var assets = pm.iterationData.get("assets");
var asset_id = assets[0].asset_id;
pm.environment.set("asset_id", asset_id);
pm.environment.set("ip", assets[0].ip);

pm.environment.set("tenant", pm.iterationData.get("tenant"));
pm.environment.set("list", pm.iterationData.get("list"));

```

Then in your request, reference as `{{agent_token}}` , `{{asset_id}}` , etc.

---

<div class="post-metadata">

**Author:** ![IrinaG1](https://avatars.discourse-cdn.com/v4/letter/i/e9c0ed/32.png) [@IrinaG1](https://community.postman.com/u/IrinaG1)\
**Post date:** [July 24, 2025, 10:53am UTC](https://community.postman.com/t/variables-are-not-substituted-in-the-performance-run-from-uploaded-data-json-while-working-correctly-in-functional-run/82756/3 "2025-07-24T10:53:39Z")

</div>

Thank you @yonandualem unfortunately none of the proposed options worked , still functional runs are working fine but in performance variables are not substituted , tried with all possible options , environment , collection variables , global none was working .

---

<div class="post-metadata">

**Author:** ![yonandualem](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/yonandualem/32/33147_2.png) [@yonandualem](https://community.postman.com/u/yonandualem)\
**Post date:** [July 24, 2025, 11:30am UTC](https://community.postman.com/t/variables-are-not-substituted-in-the-performance-run-from-uploaded-data-json-while-working-correctly-in-functional-run/82756/4 "2025-07-24T11:30:10Z")

</div>

1. **Flatten your data.json** so each variable you want to substitute is a top-level key with a simple value—no arrays or objects.
2. **Reference variables directly** in your requests:  
Use `{{$iterationData.agent_token}}`, `{{$iterationData.asset_id}}`, etc., in your request URL, headers, body, and auth fields.
3. **Remove all pre-request scripts** related to variable setting for dynamic substitution. Only use pre-request scripts for logic/calculations not involving variable assignment for the current request.

```auto
[
  {
    "agent_token": "token1",
    "asset_id": "id1",
    "ip": "1.1.1.1",
    "tenant": "tenantA"
  },
  {
    "agent_token": "token2",
    "asset_id": "id2",
    "ip": "2.2.2.2",
    "tenant": "tenantB"
  }
]

```

Try this and let me know how it goes

---

<div class="post-metadata">

**Author:** ![IrinaG1](https://avatars.discourse-cdn.com/v4/letter/i/e9c0ed/32.png) [@IrinaG1](https://community.postman.com/u/IrinaG1)\
**Post date:** [July 24, 2025, 5:05pm UTC](https://community.postman.com/t/variables-are-not-substituted-in-the-performance-run-from-uploaded-data-json-while-working-correctly-in-functional-run/82756/5 "2025-07-24T17:05:42Z")

</div>

Thank you @yonandualem i made my data structure flat and simple substituted {{agent\_token0}} , {{asset\_id0}} and etc and it worked . But i am getting new problem with authorization for totally valid tokens I am receiving in response header **WWW-Authenticate: Bearer error=“invalid\_token”, error\_description=“An error occurred while attempting to decode the Jwt: Signed JWT rejected: Another algorithm expected, or no matching key(s) found”, error\_uri=“[RFC 6750 - The OAuth 2.0 Authorization Framework: Bearer Token Usage](https://tools.ietf.org/html/rfc6750#section-3.1)”**

I checked all possible trailing spaces in data and encoding issues nothing should cause problem

 ![Screenshot 2025-07-24 at 20.05.06](https://us1.discourse-cdn.com/getpostman/original/3X/5/b/5b2b65084b6863030963a47b66ac6cbbe8f4fa02.jpeg)

Any thoughts on that ?

---

<div class="post-metadata">

**Author:** ![yonandualem](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/yonandualem/32/33147_2.png) [@yonandualem](https://community.postman.com/u/yonandualem)\
**Post date:** [July 24, 2025, 5:31pm UTC](https://community.postman.com/t/variables-are-not-substituted-in-the-performance-run-from-uploaded-data-json-while-working-correctly-in-functional-run/82756/6 "2025-07-24T17:31:30Z")

</div>

- **“Another algorithm expected, or no matching key(s) found”**  
The server expected your JWT to be signed with a specific algorithm (e.g., RS256 vs HS256), or it can’t find the public key to verify the signature.

## **Common Causes**

1. **Token Algorithm Mismatch**

- The JWT is signed with one algorithm (e.g., HS256) but the server expects another (e.g., RS256).

1. **Incorrect Signing Key**

- The key used to sign the JWT doesn’t match the public key the server uses to verify it.

1. **Malformed Token**

- The token is corrupted, has extra spaces, or is not well-formed (three parts separated by dots).

1. **Expired or Invalid Token**

- The token is expired or otherwise not valid.

1. **Test Data Copy/Paste Issues**

- Sometimes, copying tokens from Excel or JSON can introduce invisible characters or encoding problems. Even if you checked, try regenerating the tokens fresh.

---

<div class="post-metadata">

**Author:** ![IrinaG1](https://avatars.discourse-cdn.com/v4/letter/i/e9c0ed/32.png) [@IrinaG1](https://community.postman.com/u/IrinaG1)\
**Post date:** [July 24, 2025, 5:58pm UTC](https://community.postman.com/t/variables-are-not-substituted-in-the-performance-run-from-uploaded-data-json-while-working-correctly-in-functional-run/82756/7 "2025-07-24T17:58:24Z")

</div>

@yonandualem I have checked tokens in [JWT.io](http://JWT.io) and they are valid

---

<div class="post-metadata">

**Author:** ![IrinaG1](https://avatars.discourse-cdn.com/v4/letter/i/e9c0ed/32.png) [@IrinaG1](https://community.postman.com/u/IrinaG1)\
**Post date:** [July 24, 2025, 6:25pm UTC](https://community.postman.com/t/variables-are-not-substituted-in-the-performance-run-from-uploaded-data-json-while-working-correctly-in-functional-run/82756/8 "2025-07-24T18:25:03Z")

</div>

Thank you @yonandualem for help now evrything works 🙂

---

<div class="post-metadata">

**Author:** ![yonandualem](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/yonandualem/32/33147_2.png) [@yonandualem](https://community.postman.com/u/yonandualem)\
**Post date:** [July 24, 2025, 6:38pm UTC](https://community.postman.com/t/variables-are-not-substituted-in-the-performance-run-from-uploaded-data-json-while-working-correctly-in-functional-run/82756/9 "2025-07-24T18:38:55Z")

</div>

Glad I helped. Cheers!
