收藏
回答

及时配送接入预下配送单immediateDelivery.preAddOrder异常?

{

    "msg":"{\"statusCode\":200,\"body\":{\"errcode\":47001,\"errmsg\":\"data format error rid: 63253c0d-71708025-6a78b885\"},\"headers\":{\"connection\":\"close\",\"content-type\":\"text/plain\",\"date\":\"Sat, 17 Sep 2022 03:16:29 GMT\",\"content-length\":\"78\"},\"request\":{\"uri\":{\"protocol\":\"https:\",\"slashes\":true,\"auth\":null,\"host\":\"api.weixin.qq.com\",\"port\":443,\"hostname\":\"api.weixin.qq.com\",\"hash\":null,\"search\":\"?access_token=*******\",\"query\":\"access_token=*****\",\"pathname\":\"/cgi-bin/express/local/business/order/pre_add\",\"path\":\"/cgi-bin/express/local/business/order/pre_add?access_token=******\",\"href\":\"https://api.weixin.qq.com/cgi-bin/express/local/business/order/pre_add?access_token=*********\"},\"method\":\"POST\",\"headers\":{\"content-Type\":\"application/x-www-form-urlencoded\",\"accept\":\"application/json\",\"content-length\":2105}}}",

    "level":"log",

    "src":"app",

    "requestId":"1e5542f4-c399-4fd0-bd98-aea01ad8e1f3",

    "function":"immediateDelivery",

    "timestamp":"1663384589447696"

}


result: {errcode47001errmsg"data format error rid: 63253c0d-71708025-6a78b885"}

回答关注问题邀请回答
收藏

2 个回答

  • Constlu
    Constlu
    发表于移动端
    2022-09-17
    请求参数使用utf-8编码,这边看到你们的编码格式不正确哈
    2022-09-17
    有用
    回复
  • 迎宾派
    迎宾派
    2022-09-17

    return new Promise((resolve, reject) => {

        rp({

              url: 'https://api.weixin.qq.com/cgi-bin/express/local/business/test_update_order?access_token='+event.access_token,

              method: "POST",

              json: true,

              form: {

                "shopid": event.shopid,

                "shop_order_id": event.shop_order_id,

                "action_time": event.action_time,

                "order_status": event.order_status,

                "action_msg": event.action_msg,

              },

              headers: {

                  // "content-type": "application/json",

                  "content-Type": "application/x-www-form-urlencoded",

                  // 'User-Agent': 'Request-Promise'

                  // "token": event.token

              },

          }, function (error, response, body) {

              console.log(response)

              console.log(body)

              console.log(event.sender)

              console.log("响应a"+event.sender)

              resolve(body)

              if (!error && response.statusCode == 200{

                  try {

      

                  } catch (e{

                      reject()

                  }

              }

          })

      })

    是需要在headers中设置?



    按utf-8传参,还是提示参数格式不对

    {

        "msg":"{\"statusCode\":200,\"body\":{\"errcode\":47001,\"errmsg\":\"data format error rid: 632546df-6ff68c57-00d195ca\"},\"headers\":{\"connection\":\"close\",\"content-type\":\"text/plain\",\"date\":\"Sat, 17 Sep 2022 04:02:39 GMT\",\"content-length\":\"78\"},\"request\":{\"uri\":{\"protocol\":\"https:\",\"slashes\":true,\"auth\":null,\"host\":\"api.weixin.qq.com\",\"port\":443,\"hostname\":\"api.weixin.qq.com\",\"hash\":null,\"search\":\"?access_token=****\",\"query\":\"access_token=*****\",\"pathname\":\"/cgi-bin/express/local/business/order/pre_add\",\"path\":\"/cgi-bin/express/local/business/order/pre_add?access_token=******\",\"href\":\"https://api.weixin.qq.com/cgi-bin/express/local/business/order/pre_add?access_token=******\"},\"method\":\"POST\",\"headers\":{\"content-Type\":\"application/x-www-form-urlencoded;charset=utf-8\",\"accept\":\"application/json\",\"content-length\":2005}}}",

        "level":"log",

        "src":"app",

        "requestId":"35d571e6-56fe-49ea-8e8b-8c5f990cf24c",

        "function":"immediateDelivery",

        "timestamp":"1663387359685828"

    }

    2022-09-17
    有用
    回复 1
    • 迎宾派
      迎宾派
      2022-09-17
      编码格式不对的问题已经解决了JSON.stringify(参数json),这样解决
      2022-09-17
      回复
登录 后发表内容