Skip to content

Instantly share code, notes, and snippets.

@rimiti

rimiti/README.md

Created Jul 27, 2018
Embed
What would you like to do?
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
You can’t perform that action at this time.