Postman和dummy.io的数据无效

ffdz8vbo  于 2023-10-18  发布在  Postman
关注(0)|答案(1)|浏览(143)

我dummyapi.io。我正在向/user/create路由发送POST请求,请求正文中包含firstName、lastName和email字段,但是我总是收到同样的错误。有人知道是什么导致了这个问题吗?是否有任何额外的字段我应该包括或任何特定的值我应该发送?任何帮助将不胜感激。
我试图以Json格式输入数据

{
  "firstName": "Juan",
  "lastName": "Pérez",
  "email": "[email protected]"
}

这是在Postman中振铃请求的错误

{
    "error": "PARAMS_NOT_VALID"
}

以下是dummyapi.io文档中所说的:

Create User
Create new user, return created user data.
Body: User Create (firstName, lastName, email are required)
POST
/user/create
Response: User
bttbmeg0

bttbmeg01#

你需要确保你有:

  • 设置了有效的app-id HTTP请求标头
  • 有效URL:https://dummyapi.io/data/v1/user/create
  • 预期请求方法:POST
  • Content-Type header应该设置为application/json(在Postman中选择Body -> Raw -> JSON (from the dropdown)
  • 一个有效的请求体(见下文)

我已经在curl和Postman中成功测试了以下请求:

curl --location 'https://dummyapi.io/data/v1/user/create' \
--header 'app-id: <replace-with-your-app-id>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "firstName": "myFirstname",
  "lastName": "myLastname",
  "email": "[email protected]"
}'

您可以只运行curl命令,也可以使用Import将其导入Postman,然后粘贴命令。

预期结果应该是沿着这条线:
状态200 Ok

{
    "id": "64d515120dc40b433a86eb5f",
    "firstName": "myFirstname",
    "lastName": "myLastname",
    "email": "[email protected]",
    "registerDate": "2023-08-10T16:49:22.275Z",
    "updatedDate": "2023-08-10T16:49:22.275Z"
}

相关问题