AdSense

網頁

2023/10/17

Postman 設定本地變數 set local variables

Postman發送請求所在Pre-request Script設定本地變數(local variables)。


在Postman請求的[Pre-request Script]頁籤中,使用pm.variables.set設定本地變數值。例如下面設定一個本地變數id的值為e2bf464a-7e7a-4366-a6d0-d06e7da6c34d

pm.variables.set("id", "e2bf464a-7e7a-4366-a6d0-d06e7da6c34d")

然後可在請求的url、參數或payload中以{{id}}取值。注意在請求payload的JSON欄位若為字串值,前後仍要用"包住,例如"{{id}}"





沒有留言:

AdSense