0

Sorry for my english.

I develop Ruby On Rails app (4.2.4) which interacts with Gitlab CI API ( using ActiveResource). I have list of projects on my remote resource and want to get it.

I created model GitlabResource:

require 'active_resource'
class GitlabResource < ActiveResource::Base
  self.site = 'http://gitlab.example.com/ci'
  self.include_format_in_path = false
end

And Project model

class Project < GitlabResource
  self.prefix = '/api/v1/'
end

The docs says that one of the ways of authentication is with GitLab user token & GitLab url. And I need to add this parameters in each request.

when I use curl it works well:

curl http://gitlab.example.com/ci/api/v1/projects?private_token=AAAAQQQQAAAd&url=http://gitlab.example.com/

How can I add these parameters to the model GitlabResource? And do something like this:

@projects = Project.all

Upd. When I do

@projects = Project.find(:all, :params => { :private_token => 'AAAAQQQQAAAd', :url => 'http://gitlab.example.com/'})

Get error

Failed. Response code = 500. Response message = Internal Server Error.

Whats wrong?

McCauley
  • 15
  • 5

1 Answers1

0
class Project < GitlabResource
  headers["PRIVATE-TOKEN"] = 'AAAAQQQQAAAd'
  self.prefix = '/ci/api/v1/'
end

It works well now.

McCauley
  • 15
  • 5