Chris Walls

Using SamanageAPI.rb with Ruby

Discussion created by Chris Walls Administrator on Aug 5, 2015

The following scripts are provided by Samanage as examples and training purposes only and not designed to work in every use case without some modification to the script itself. These scripts are not supported by Samanage as part of your Samanage Master Subscription Agreement, however if you would like this script customized to support your use case, please contact us at for a personal quote.


SamanageAPI is a simple Ruby file that provides a simple platform for working with the Samanage API.

How to use

SamanageAPI is a ruby Class that allows you to easily generate API calls to Get/Post/Put items into Samanage by passing a path, email, user and optional data as arguments. To begin using this function, simply require SamanageAPI.rb in your ruby script.

require_relative 'SamanageAPI.rb'


Getting data from Samanage

Example: To 'get' users

users = SamanageAPI.get("users.xml", "","password")

When successful users will contain hash with the following keys:


Creating user in Samanage

email = ""
pass = "password"
xml = "John"
call ="users.xml", email, pass, xml)

Updating users in Samanage

xml = "value"
call = SamanageAPI.put("users/USER_ID.xml", email, pass, xml)

When correct information is entered call["success"] should be set to true and call["code"] will return 201 (Created)