pass JSON to HTTP POST Request

后端 未结 9 2052
傲寒
傲寒 2020-11-29 18:22

I\'m trying to make a HTTP POST request to the google QPX Express API [1] using nodejs and request [2].

My code l

9条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 19:18

    I worked on this for too long. The answer that helped me was at: send Content-Type: application/json post with node.js

    Which uses the following format:

    request({
        url: url,
        method: "POST",
        headers: {
            "content-type": "application/json",
            },
        json: requestData
    //  body: JSON.stringify(requestData)
        }, function (error, resp, body) { ...
    

提交回复
热议问题