如何将日期时间放入正文 POSTMAN如何将、放入、日期、时间

2023-09-07 11:18:11 作者:斯文败类

我试过这个,但对我没有用.我得到了date_creation"的 NULL 值.在数据库(Mysql)中

I tried this one but didnt work for me. I got NULL value of "date_creation" in DB (Mysql)

我使用预请求脚本选项卡将日期保存到变量中:

I used Pre-request script tab to save the date into a variable:

var current_timestamp = new Date();
postman.setEnvironmentVariable("current_timestamp", current_timestamp.toISOString());

{
    "rib": "123456789",
    "code_client": "3",
    "taux":"19",
    "decouvert" : "150",
    "solde" : "8500",
    "date_creation" : "{{current_timestamp}}"
    
}

推荐答案

您必须选择 Raw 并为请求正文键入 JSON

You have to select Raw and type JSON for request body

您可以通过打开控制台视图查看发送到数据库的内容>显示邮递员控制台

You can check what was send to database by opening console view>show postman console

然后在控制台点击请求>请求正文

and then click the request>request body in the console

WH 显示实际发送到服务器的内容.

WHich shows what was actually send to server.

如果它仍然失败,那么它不是邮递员的问题,而是你的应用程序

If its still failing then its not issue with postman but your application