I'm trying to use someone's API to retrieve data. Here's a plain curl GET that works fine:
$ curl -H 'Authorization: Bearer eyJhbGciOiJSUz...' 'https://app.theirsite.com/api/web/call/call-log?q=\{"pageSize":25,"pageIndex":1,"sortBy":"timeConnected","sortDirection":2,"userAccountId":0,"requestorId":0,"companyAccountId":99,"consumerId":null,"ticksSince":636959988000000000,"ticksUntil":636966899990000000,"callStatusId":1\}'
Note the escaped brackets.
I can't get this to work in rails with curb. I've tried various attempts at formatting the parameters following the '?' in the url, but no luck. Here's my last attempt:
params = {"pageSize": 25,
"pageIndex": 1,
"sortBy": "timeConnected",
"sortDirection": 2,
"userAccountId": 0,
"requestorId": 0,
"companyAccountId": 99,
"consumerId": nil,
"ticksSince": 636959988000000000,
"ticksUntil": 636966899990000000,
"callStatusId": 1}
params_str = JSON[params].to_s
params_str.insert( -2, '\\')
response = Curl.get("https://app.theirsite.com/api/web/call/call-log?q=\\" + params_str ) {|curl|
curl.headers['Authorization'] = 'Bearer ' + @saved.token
curl.verbose = true}
The authorization is fine, but their server is responding with a 500 error {"global":["Index was outside the bounds of the array."]}. This is what I was getting with a direct curl command before I figured out I needed the escaped brackets. I haven't figured out how to get curb to provide an output of the complete url before sending. That would be helpful.
Any thoughts.