'pass variable in put request python

I am new to python. basically I am writing pytest for APIs. So this code works

response = requests.put('{host}/persons/1234567/'.format(host=url),data=params, headers=headers)

Now I would like to replace number(1234567) with variable in the request body. I tried below and other things also

id = 1234567

response = requests.put('{host}/persons/id/'.format(host=url),data=params, headers=headers)

But it does not works.

Could you help me out to construct request body which consist variable



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source