Connecting to Highrise CRM using Web Services

Source code

Here is the source code for the highrise module. To use it:

  1. Create a new shared module called “highrise” and copy paste in the code below.
  2. Add the code require(‘highrise’) at the top of the main module.
  3. Test using sample data.

Code for main:

require('highrise')

URL_p='https://interfaceware.highrisehq.com/people.xml' -- url for people (create or read all)
URL_fs='https://interfaceware.highrisehq.com/people/70421633-fred-smith.xml' --individual example url for read

function main(Data)
   print(highrise,_G)
   local msg, name = hl7.parse({vmd = 'demo.vmd', data = Data})
   local T = highrise.InsertTemplate()
   T=mapPatientData(T,msg,name)

   -- read an individual contact from highrise
   local R,C,H = net.http.get{url=URL_fs,live=true,
      auth={username='Your Highrise API Token here', password='X'}}
   print(C,R,H)
   -- read all contacts (only change is the URL)
   R,C,H = net.http.get{url=URL_p,live=true,
       auth={username='Your Highrise API Token goes here', password='X'}}
   print(C,R,H)

   -- create a new contact in highrise
   R,C,H=net.http.post{url=URL_p,live=false,  -- live=true, -- for testing
      auth={username='Your Highrise API Token goes here', password='X'},
      headers={['Content-Type']='application/xml'},
      body=T:S()
   }
   print(C,R,H) -- code 201 (c=201) is a successful insert
end

function mapPatientData(Xml,Msg,Name)
   if Name=='ADT' then
      Xml.person["first-name"][1]=Msg.PID[5][1][2]
      Xml.person["last-name"][1]=Msg.PID[5][1][1][1]
   end
   return Xml
end

, 'fIncludeLineNumbers

Code for highrise module:

highrise={}

function highrise.InsertTemplate()
   return xml.parse
   {data=
      '<person>'..
      '  <first-name>#</first-name>'..
      '  <last-name>#</last-name>'..
--      '  <background>#</background>'..
--      '  <title>#</title>'..
--      '  <company-name>#</company-name>'..
      '</person>'
   }
end

function node.S(ANode)
   return tostring(ANode)
end

Possible modifications interesting notes etc:

  • You need to use the API token from your own Highrise account to logon (replace “Your Highrise API Token here” on lines 14, 18 and 23 of main)
  • Gotcha: you need placeholders like # in the XML template (highrise module), deleting them causes errors in mapPatientData() – try it and see if you want.
  • There are three other Contact fields you can include in the insert <background>, <title> and <company-name>
  • Adding personal details to contacts
  • When I tried an insert including contact data (email, phone, address etc) the <contact-data> segment was ignored
  • When I tried an insert with a <tag> segment the insert failed
  • Try an update using the Contact Id in the returned Header Message (the H return in the code)
  • The XML formats on the highrise API reference page are not 100% clear, I suggest using Highrise to update a contact , and looking at the returned XML.

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.