I am trying to make a post request to Highrise API using the npm package node-highrise-api
. It takes XML and I have been getting a response from the API but unsuccessfully passing data. Here's my code:
studentNote = "<note><body>hello</body><subject-id type=\"integer\">267869152</subject-id><subject-type>Status Change</subject-type></note>"
rp.post "https://token:a@name.highrisehq.com/people/id/notes.xml", studentNote
.then (response) ->
highriseData = xml2js.parseStringAsync response, {trim: true}
console.log highriseData
.catch (err) ->
console.log 'this err'
console.log err
null
rp is request-promise, an npm package that enables promises with the request npm package.
The response is:
<?xml version="1.0" encoding="UTF-8"?>
<note>
<author-id type="integer">1232986</author-id>
<collection-id type="integer" nil="true"></collection-id>
<collection-type nil="true"></collection-type>
<created-at type="datetime">2016-09-22T20:52:16Z</created-at>
<group-id type="integer" nil="true"></group-id>
<id type="integer">381833222</id>
<owner-id type="integer" nil="true"></owner-id>
<subject-id type="integer">267869152</subject-id>
<subject-type>Party</subject-type>
<updated-at type="datetime">2016-09-22T20:52:16Z</updated-at>
<visible-to>Everyone</visible-to>
<body nil="true"></body>
<subject-name>Parentof Student</subject-name>
</note>
If you look at the body, subject id, and subject type tags, the data I passed is not being sent back in the response.
Does anyone have any suggestions for dealing with an XML API?
Thanks in advance