通过Postman发送JSON的timstamp

时间:2021-10-17 18:14:18

I'm fairly new to working with REST APIs and Postman and I'm looking for a way to include a timestamp as a string in a POST request body via Postman.

我很擅长使用REST API和Postman,我正在寻找一种方法,通过Postman将时间戳作为字符串包含在POST请求体中。

According to the Postman docs, there is a dynamic variable {{$timestamp}} which can be used in the request body. However, when I try to use it, I get a 400 back from the endpoint I am POSTing to with the message "malformed data."

根据Postman文档,有一个动态变量{{$ timestamp}}可以在请求体中使用。但是,当我尝试使用它时,我从正在发布的端点获得400返回,并显示消息“格式错误的数据”。

Here are a couple of variations I have tried:

以下是我尝试的几种变体:

variation 1

[
    {
        "from_number": "+123456789",
        "messages": [
            {
                "text":  "Message at" {{$timestamp}},
                "to_number": "+123456789"
            }
        ]
    }
]

variation 2

[
    {
        "from_number": "+123456789",
        "messages": [
            {
                "text":  "Message at {{$timestamp}}",
                "to_number": "+123456789"
            }
        ]
    }
]

variation 3

[
    {
        "from_number": "+123456789",
        "messages": [
            {
                "text":  "Message at " + {{$timestamp}},
                "to_number": "+123456789"
            }
        ]
    }
]

All of these have returned the same error

所有这些都返回了相同的错误

{
  "errorMessage": "malformed data",
  "error": true
}

1 个解决方案

#1


4  

Thanks @NimS and @JAAulde: Varation 2 is the correct answer. The problem must have been a typo.

谢谢@NimS和@JAAulde:Varation 2是正确答案。这个问题肯定是一个错字。

#1


4  

Thanks @NimS and @JAAulde: Varation 2 is the correct answer. The problem must have been a typo.

谢谢@NimS和@JAAulde:Varation 2是正确答案。这个问题肯定是一个错字。