首页 > 解决方案 > 邮递员的回应是一个,但使用另一种工具 - 回应是另一个

问题描述

我有POST要求:https://account.mail.ru/api/v1/user/signup。当我使用它来获取它时,Postman它可以正常工作:

请求(表单数据):

password=justpassword2281337
domain=mail.ru
name={"first":"firstName","last":"lastName"}
login=justlogin.any123
extended=true

响应(这是正确的响应):

{
    "body": {
        "additional": {},
        "token": "token"
    },
    "status": 200,
    "htmlencoded": false
}

但是,当我尝试使用 curl 时:

curl --location --request POST 'https://account.mail.ru/api/v1/user/signup' \
     --form 'password="justpassword2281337"' \
     --form 'domain="mail.ru"' \
     --form 'name="{\"first\":\"firstName\",\"last\":\"lastName\"}"' \
     --form 'login="justlogin.any123"' \
     --form 'extended="true"'

响应(无效响应):

{
   "body":{
      "phones":{
         "value":null,
         "error":"required"
      }
   },
   "email":null,
   "status":400,
   "htmlencoded":true
}

后端要我提供电话。

在此之后,我尝试了很多东西:

  1. 更改标题(Content-Type、User-Agent 等)
  2. 使用VPN,使用代理
  3. 设置cookies,删除cookies
  4. 试图在https://reqbin.com/中重复此请求

此外,我尝试使用原始请求重复此HTTP请求。我为此使用了 BurpSuite 中继器实用程序。

原料HTTP

POST /api/v1/user/signup HTTP/1.1
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Cache-Control: no-cache
Postman-Token: 2e8f4c93-45e7-4a6e-9485-84eea151223d
Host: account.mail.ru
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Type: multipart/form-data; boundary=--------------------------799760626318920619393512
Content-Length: 671
----------------------------799760626318920619393512
Content-Disposition: form-data; name="password"

justpassword2281337
----------------------------799760626318920619393512
Content-Disposition: form-data; name="domain"

mail.ru
----------------------------799760626318920619393512
Content-Disposition: form-data; name="name"

{"first":"firstName", last":"lastName"}
----------------------------799760626318920619393512
Content-Disposition: form-data; name="login"

justlogin.any123
----------------------------799760626318920619393512
Content-Disposition: form-data; name="extended"

true
----------------------------799760626318920619393512--

我也尝试使用newmanpostman-requestnpm 库:

const request = require('postman-request');
request.post('https://account.mail.ru/api/v1/user/signup', {
    form: {
        password: 'justpassword2281337',
        name: JSON.stringify({
            first: "firstName",
            last: "lastName"
        }),
        login: 'justlogin.any123',
        domain: 'mail.ru',
        extended: true
    }
}, (err, res, body) => {
    console.log(res, body)
})
const newman = require('newman')

newman.run({
    collection: 'collection.json' // collection.json is exported from postman collection
}).on('request', function (error, data) {
    if (error) {
        console.error(error);
    }
    else console.log(data.response.stream.toString())
});

但是我所有的尝试都是徒劳的,后端给了我同样的回复,并要求我提供电话(

我认为Postman发送请求与其他工具不同。

标签: postman

解决方案


推荐阅读