Can I use _.random for a single variable, but several times in 1 request

Hello, so, I have I’m trying to create a post request that uses raw json data and it kinda fills in a review process. I want to randomize the part where I input the rating (1 to 10).
I’ve stumbled on 2 issues tho,
the first is that I get a bad request 400 -

Can not deserialize value of type java.lang.Integer from String "{{randomN}}"

let randomN = (_.random(1,10)); pm.globals.set("randomN", randomN);

the second issue, well it is more like what I predict will be my 2nd issue is that I want to use randomN 5-6 times in the request, would I have to create 5-6 variables that would be randomized as it will likely be the same number if I use randomN more than once

Edit- fixed my first issue by moving the script to pre-request, still trying to figure out the optimal way to generate random numbers from 1 to 10, id prefer if i can do it with a single variable rather than a new variable for every time I want to call it in the request

2nd edit - I just created 5 variables for 1 to 10, anyway if more optimal way, id love the suggestion

Hi @theToncheff,

Welcome to the community. :wave:

I have attached a sample collection below which generates 10 different random numbers using a single environment variable - you can use these random generated numbers in your API call. Please take a look at it.
https://www.getpostman.com/collections/5dd505b1a25f8c250344

Hope this helps.