# The path variable "var" needs to be of type integer, but we found "{{var}}"

**URL:** <https://community.postman.com/t/the-path-variable-var-needs-to-be-of-type-integer-but-we-found-var/12714>\
**Category:** Help Hub\
**Tags:** json\
**Created:** [May 18, 2020, 8:33am UTC](https://community.postman.com/t/the-path-variable-var-needs-to-be-of-type-integer-but-we-found-var/12714 "2020-05-18T08:33:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![plcmaechler](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/plcmaechler/32/4500_2.png) [@plcmaechler](https://community.postman.com/u/plcmaechler)\
**Post date:** [May 18, 2020, 8:33am UTC](https://community.postman.com/t/the-path-variable-var-needs-to-be-of-type-integer-but-we-found-var/12714/1 "2020-05-18T08:33:46Z")

</div>

Hello Again  
In my Environment I set a variable `var = 1` and use that one in the URL

Now my put operation yields an issue:  
`1 Issue found while validating against PUT /api/workspace/{workspaceId}`

When I change the URL to /api/workspace/:workspaceId and use a path variable, the test is successfull

Is there a way to use the environment vars in those tests?  
Even when using the URL with :workspaceId and setting the path variable workspaceId to the environment variable {{workspaceId} the test fails

I somehow don’t want to use local variables for tests, especialy when chaining them

---

<div class="post-metadata">

**Author:** ![plcmaechler](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/plcmaechler/32/4500_2.png) [@plcmaechler](https://community.postman.com/u/plcmaechler)\
**Post date:** [May 18, 2020, 8:38am UTC](https://community.postman.com/t/the-path-variable-var-needs-to-be-of-type-integer-but-we-found-var/12714/2 "2020-05-18T08:38:03Z")

</div>

Looks like this is the same as [The path variable needs to be of type number, but we found "{{id}}"](https://community.postman.com/t/the-path-variable-needs-to-be-of-type-number-but-we-found-id/12703)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [May 18, 2020, 8:39am UTC](https://community.postman.com/t/the-path-variable-var-needs-to-be-of-type-integer-but-we-found-var/12714/3 "2020-05-18T08:39:50Z")

</div>

Hey @plcmaechler

Are you able to show an example of what you’re seeing in the app and the test code that you’re using to get/set the variables please?

---

<div class="post-metadata">

**Author:** ![plcmaechler](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/plcmaechler/32/4500_2.png) [@plcmaechler](https://community.postman.com/u/plcmaechler)\
**Post date:** [May 18, 2020, 8:44am UTC](https://community.postman.com/t/the-path-variable-var-needs-to-be-of-type-integer-but-we-found-var/12714/4 "2020-05-18T08:44:09Z")

</div>

Well there is no “test code” involved

Let’s share the information firts:

This is the definition in the API:  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/4/8/48299daa76bc2b065c4dc0604e79194614da8bdb.png)

And here is the request from my collection:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/0/3079b3d11b3ef082b21a53fd62af0f19e28ac3e8.png)

And when i test the API, postman reports the error:  
 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/f/f09e7d8e75e4dc06a071db4cd691363221264b39.png)

When I use a path variable, the API test is ok  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/6/8/684c5d24d6a0c7743759dd62cfc9c832482d5319.png)

and to summ it all up, the variables are defined in an environment

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/4/e/4ea34ac83cfe15b6d245b403c7cb65465498f81c.png)  
hope that helps

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [May 18, 2020, 9:43am UTC](https://community.postman.com/t/the-path-variable-var-needs-to-be-of-type-integer-but-we-found-var/12714/5 "2020-05-18T09:43:23Z")

</div>

My bad - When people talk about variables, my mind instantly goes to getting or setting them via a script with `pm.environment.get()` / `pm.environment.set()` 😃

So it’s failing to validate the request against your schema when you use an environment variable as a path parameter value?

![Screenshot 2020-05-18 at 10.36.19](https://us1.discourse-cdn.com/getpostman/original/2X/c/c8c0a69e5050c2f6f4be50e80b2fb4a3da26eb54.png)

---

<div class="post-metadata">

**Author:** ![plcmaechler](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/plcmaechler/32/4500_2.png) [@plcmaechler](https://community.postman.com/u/plcmaechler)\
**Post date:** [May 18, 2020, 10:04am UTC](https://community.postman.com/t/the-path-variable-var-needs-to-be-of-type-integer-but-we-found-var/12714/6 "2020-05-18T10:04:46Z")

</div>

yes

the API endpoint is defined as `/api/workspace/{workspaceId}:` and requires a parameter `workspaceId ` in path

the request is `{{baseUrl}}/api/workspace/{{workspaceId}}` and this fails (looks to me I have to use an path variable when testing the API)

therefore my next attemp was to set the path variable to {{workspaceId}} from environment which also does not work

Only when using the path variable and put a “static” value in the, the API validation is working

is there a way to directly use the environment variable, or set the path variable to the environment variable in a pre-reqeust script?

thx for your help so far

---

<div class="post-metadata">

**Author:** ![mason](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@mason](https://community.postman.com/u/mason)\
**Post date:** [May 20, 2020, 2:54am UTC](https://community.postman.com/t/the-path-variable-var-needs-to-be-of-type-integer-but-we-found-var/12714/7 "2020-05-20T02:54:52Z")

</div>

Okay. Not totally sure what you are trying to do and why it is or isn’t working, but from the images, it looks like you should “stick” with the path vars, but combine it with the {{workingId}} you add by putting that as the value for the path var.

This one is showing using the dynamic vars for a uuid:

 ![Screen Shot 2020-05-19 at 10.46.04 PM](https://us1.discourse-cdn.com/getpostman/original/3X/0/f/0faa792a5825aa36f32a4a5726654a3e694f9391.png)

And here is is with your “1” in it:

 ![Screen Shot 2020-05-19 at 10.46.44 PM](https://us1.discourse-cdn.com/getpostman/original/3X/a/c/acf089d4eeaeebb866abd43e420f500db6cd9a94.png)

One thing to note, if you want to have your example use the value you pass on one of the postman mock server instances, you need to change the url value of your example to use a variable, like this:  
`{{url}}/workspaces/{{workspaceid}}`  
that way it can be used as a substitution in the response with "{{workspaceid}} on the mock server like this:

> {  
> “workspaceid”:“{{workspaceid}}”  
> }

---

<div class="post-metadata">

**Author:** ![plcmaechler](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/plcmaechler/32/4500_2.png) [@plcmaechler](https://community.postman.com/u/plcmaechler)\
**Post date:** [May 20, 2020, 5:40am UTC](https://community.postman.com/t/the-path-variable-var-needs-to-be-of-type-integer-but-we-found-var/12714/8 "2020-05-20T05:40:47Z")

</div>

Hello Mason

For requests from within a Collection, this approach (using a path variable and setting it to the environment var) is working fine and all the calls and tests are successfull

The problem-part is when i test or validate the API.  
On the postman website I go into my API and from there to Test  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/2/3/2334c61ad5f3149de148b86fe45a79a5b3bfa3e5.png)

Then I see the test-suite that I created (the collection). If I validate the API schema against it, I get the error mentioned.

It looks like when I test the API, the environment is “ignored” or no environment is used.

---

<div class="post-metadata">

**Author:** ![plcmaechler](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/plcmaechler/32/4500_2.png) [@plcmaechler](https://community.postman.com/u/plcmaechler)\
**Post date:** [June 10, 2020, 1:28pm UTC](https://community.postman.com/t/the-path-variable-var-needs-to-be-of-type-integer-but-we-found-var/12714/9 "2020-06-10T13:28:34Z")

</div>

Unfortunately my problem is still not solved. I’m getting the feelding, that my question/problem is not clear

I have six request in my Collection

1. /login
2. /user/create
3. /user/read/:userId
4. /user/change/:userId
5. /user/delete/:userId
6. /user/read/:userId

when loggin in, the accessToken is saved as an environment variable  
when creating an user, the response is the userId, which is also saved as an environment variable  
when reading the object, the PathVariable is set to the environment Variable

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/e/e469a63642862b400ba537ecffff5e5e04c4fb67.png)

This setup is working fine. I can send those request and all return with a status code of 200 and the object is added, changed and deleted

In Postman i also have an API which has the above Test Suite linked to it. There when I click on validate the, the schema has issues  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/6/0/60e6242d40ce1f1ea4c3d4465ea95f7ccdbc4101.png)

I’m sure this is something trivial because it feels like a basic test routine which I’m sure lots of you already did .)

May someone be able to sched some light into the darknes and gives me a hint on how to solve?

When I “hardcode” the ID, the validation wors fine, so i certain that it has to do with the {{variable}} syntax
