Skip to content

Instantly share code, notes, and snippets.

@rimiti
Created July 27, 2018 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rimiti/01722f5aff7f9317054077600ce2cf7e to your computer and use it in GitHub Desktop.
Save rimiti/01722f5aff7f9317054077600ce2cf7e to your computer and use it in GitHub Desktop.
Sending JSON object into form data field with request

Sending JSON object into form data field with request

How to run it?

npm i request -S
const request = require('request');
const dataString = 'patient={"first_name":"John","name":"Doe","email":"john.doe@test.com","birth_date":"20/01/1991","mobile_phone":"0102030405","gender":"male","external_id":"2934640871"}';
const options = {
url: 'https://devapi.share-meeting.com/cs-clicrdv/set_patient.aspx?ccode=990781023',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: dataString
};
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
}
}
request(options, callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment