npm i request -S
Created
July 27, 2018 08:33
-
-
Save rimiti/01722f5aff7f9317054077600ce2cf7e to your computer and use it in GitHub Desktop.
Sending JSON object into form data field with request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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