0

I need to send a request. If I have copied this request and executed on postman and it works. Postman is sending it as a raw. Is there anyway that I can convert my formData object to raw?

I tried to use the lib npm i form-urlencoded and encodeURI and both didnt work.

I need to convert object to raw type. How can I do it?

Tiago Castro
  • 421
  • 6
  • 20

1 Answers1

0

There is no raw content-type.

I just tested the raw option in postman and send to a dummy netcat server.

The request arrived with Content-Type: text/plain;


If you need to send application/x-www-form-urlencoded then edit your object with following function example (from here):

serialize = function(obj) {
  var str = [];
  for (var p in obj)
    if (obj.hasOwnProperty(p)) {
      str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
    }
  return str.join("&");
}
Kristianmitk
  • 4,528
  • 5
  • 26
  • 46