Search code examples
rubyrallyrest-client

Unable to invoke Rally LBAPI WS from ruby rest-client program. Any


I have been able to query rally analytics API using DHC(Dev HTTP Client) with the following POST request http://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1234/artifact/snapshot/query.js&API_Key=key123 and body { "find": { "ObjectID": 4321 } }

Is there any way I can do this from Ruby? I have using 'rest-client' but am only getting errors endlessly (400, 403, ....) Has anyone been able to do this ? Is this possible using curl?


Solution

  • It's possible using both curl and ruby. You need to set a ZSESSIONID header value equal to your API Key. Curl example here (randomized Workspace OID and API Key):

    curl -X POST \
    'https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/12345678910/artifact/snapshot/query' \
    -H 'content-type: application/json' \
    -H 'accept: application/json' \
    -H 'ZSESSIONID: _m31qjdm43Ou74h0cACk28zgBUOPm50Xtna2PhQ2L22' \
    --data '{"find":{"FormattedID": "DE9", "__At": "current"},"fields":true,"start":0,"pagesize":10,"removeUnauthorizedSnapshots":true}' \
    --compressed
    

    It is fairly straightforward to do in Ruby also. The following Gists:

    Contain a Ruby connection helper for connecting to Rally's Lookback API. The second Gist contains an example of using the connection helper along with a hash representing a find query object. The Ruby example uses httpclient gem as opposed to rest-client gem, but the concept is the same.