IDEA HTTP Client 内置变量

IDEA HTTP Client About 822 words

时间类

Unix 时间戳

精确到秒级别。

{{$timestamp}}

输出:

1671591225

毫秒级时间戳

手动添加000即可。

{{$timestamp}}000

输出:

1671591316000

日期

请求头中可以不加双引号(获取时使用getHeader(),不同语言实现不同),在请求体中如果是以String字符串对象接收,则需要添加双引号。

< {%
let timestamp = Date.now();
request.variables.set("ts", timestamp.toString());
%}
POST http://localhost:8080/api/login
Content-Type: application/json
X-Timestamp: {{ts}}

{
  "ts": "{{ts}}"
}

{{ts}}输出:

1671591225116

ISO 时间戳

{{$isoTimestamp}}

输出:

2022-12-20T09:27:39.089053Z

随机数

uuid

{{$uuid}}

输出:

1603714f-e234-4dc2-ad19-0de310ce6bd3

random uuid

{{$random.uuid}}

输出:

dbe991fb-3b4e-448b-9572-01ef130df339

数字 + 大小写字母

参数为生成的字符串长度,此处示例为10

{{$random.alphanumeric(10)}}

输出:

LD3BqMUSbA

纯大小写字母

参数为生成的字符串长度,此处示例为10

{{$random.alphabetic(10)}}

输出:

wipSKmoMcA

邮件地址

{{$random.email}}

输出:

YJVa1ZkWTtimPmRVHF@ExPVW.de

int 值

{{$randomInt}}

输出:

415
Views: 1,121 · Posted: 2023-05-28

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh