最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

请求状态码为404,但在邮递员

IT培训 admin 2浏览 0评论

请求状态码为404,但在邮递员

我正在尝试使用请求从节点访问API。它给出的statusCode为404,但出人意料地在邮递员中工作

var options = {
  method: 'POST',
  url: ',
  headers:   { 
    'cache-control': 'no-cache',
    'Connection': 'keep-alive',                   
    'Host': 'soandsourl',                   
    'Cache-Control': 'no-cache',
    'Accept': '*/*',
    'User-Agent': 'PostmanRuntime/7.17.1',
    'Content-Type': 'application/json'
  },
  body: reqParams,
  json: true
};

request(options, function (error, response, body) {
  console.log(error, "error++++");
  // console.log(response, "response++++");
  console.log('statusCode:', response && response.statusCode);
});

你们能帮忙吗,这里缺少什么?

回答如下:

邮递员本身会添加一些标头(临时),您的服务器中大部分不需要。假设您使用的是您的API请求选项中提到的代码段,请删除多余的标头,然后重试。

请求状态码为404,但在邮递员

我正在尝试使用请求从节点访问API。它给出的statusCode为404,但出人意料地在邮递员中工作

var options = {
  method: 'POST',
  url: ',
  headers:   { 
    'cache-control': 'no-cache',
    'Connection': 'keep-alive',                   
    'Host': 'soandsourl',                   
    'Cache-Control': 'no-cache',
    'Accept': '*/*',
    'User-Agent': 'PostmanRuntime/7.17.1',
    'Content-Type': 'application/json'
  },
  body: reqParams,
  json: true
};

request(options, function (error, response, body) {
  console.log(error, "error++++");
  // console.log(response, "response++++");
  console.log('statusCode:', response && response.statusCode);
});

你们能帮忙吗,这里缺少什么?

回答如下:

邮递员本身会添加一些标头(临时),您的服务器中大部分不需要。假设您使用的是您的API请求选项中提到的代码段,请删除多余的标头,然后重试。

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论