简体   繁体   English

帖子正文中缺少必需的参数 To

[英]Missing required parameter To in the post body

I'm not sure if the header or the body are configured incorrectly.我不确定标题或正文是否配置不正确。 Any thoughts on whether to change the headers or maybe the body is misconfigured?关于是否更改标题或主体配置错误的任何想法?

const axios = require('axios');
  const url = '/my_url';
  const auth = {
    username: username,
    password: password
  };

  const requestbody = {
    To: 'phone',
    From: 'phone 2'
  };

  const headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
  }
  const config = {
    auth: auth,
    headers: headers
  }

  try {
    const response = await axios.post(url, {data: requestbody}, config);
    console.log(response);
  } catch (error) {
    console.error(error);
  }

Error like: message: 'Missing required parameter To in the post body'错误如: message: 'Missing required parameter To in the post body'

you need to stringify parameters and then pass directly你需要对参数进行字符串化,然后直接传递

const querystring = require('query-string');

  const query = querystring.stringify({
  To: 'phone',
    From: 'phone 2'
  });
  let options = {
    headers: {
      'Authorization': AUTH_HEADER,
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  };
    let axios_res = await post(url, query , options);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 浏览器中缺少 SpringBoot 所需的请求正文 - SpringBoot Required request body is missing from browser Cloudinary \\ Error:缺少必需参数 - 文件 - Cloudinary\Error: Missing required parameter - file 无法读取 Express for POST 中的正文参数 - Can't read body parameter in Express for POST 发布错误必需的MultipartFile []参数不存在 - post error Required MultipartFile [ ] parameter not present org.springframework.http.converter.HttpMessageNotReadableException:缺少所需的请求正文 - org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing 缺少必需的参数 - public_id,以及为 Cloudinary 分配给 imageId 的内容 - Missing required parameter - public_id, and what to assign to imageId for Cloudinary LinkedIn oauth错误缺少必需参数“client_id” - LinkedIn oauth error A required parameter “client_id” is missing Shopify / Liquid - 重命名错误“必需参数丢失或无效” - Shopify / Liquid - rename the error "Required parameter missing or invalid" 邮差。 获取令牌。 错误:“缺少参数:\\”代码\\“是必需的” - Postman. Get a token. Error: “Missing parameter: \” code \ “is required” 即使缺少所需架构的一部分,GraphQL POST 也会通过 - GraphQL POST passes even though parts of required schema are missing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM