This script demonstrates how to submit a Query request to return all users using Ruby on RepliConnect:

require 'net/http'
require 'json'

# Change these parameters to point at any Web TimeSheet instance
# http://$host:$port/$path
$host = 'hostcomputername' 
$port = 81
$path = '/TimeSheet/RemoteApi/RemoteApi.ashx/8.17'
$loginname = 'admin'
$password = 'password'

# Make a RepliConnect API web service call, and return the response data
def remote_api(input)
    request =$path, initheader = {'Content-Type' => 'application/json' })
    request.basic_auth($loginname, $password)
    request.body = JSON.generate(input)
    puts "Request: #{request.body}"
    response =$host, $port).start {|http| http.request(request) }
    puts "Response #{response.body}"
    return response.code, JSON.parse(response.body)

# Make a RepliConnect API web service call, and verify that the call succeeded
# without any errors.
def remote_api_success(input)
    code, body = remote_api(input)
    if code.to_i != 200
        raise "Expected success code 200, was #{code} instead"
    elsif body["Status"] != "OK"
        raise "Expected status 'OK', was #{body["Status"]} instead"
    return body

# Query to return all users
request = JSON.parse(%Q!
        "Action": "Query",
        "QueryType": "UserAll",
        "DomainType": ""Replicon.Domain.User",
        "Args": []     }
response = remote_api_success(request)

Free trial

Hassle-Free Time Tracking Software from Replicon. Start your Free Trial Today!

Get Started