Internal Server Error with Calling API

I am trying Mautic on Ruby. When I send a GET HTTP request to ‘http://my-mautic/api/contacts?access_token=my_access_token’ with a header ‘Authorization: Bearer my_access_token’, I get the Internal Server Error (500). The log (‘my-mautic/s/sysinfo’) says

Code:
[2017-07-27 09:31:48] mautic.CRITICAL: Uncaught PHP Exception OAuth2OAuth2AuthenticateException: "invalid_request" at /home/foo/bar/public_html/ma/vendor/friendsofsymfony/oauth2-php/lib/OAuth2.php line 570 {"exception":"[object] (OAuth2\OAuth2AuthenticateException(code: 0): invalid_request at /home/foobar/public_html/ma/vendor/friendsofsymfony/oauth2-php/lib/OAuth2.php:570)"} []
What I did is:
Code:
require 'faraday'; require 'faraday_middleware' token = 'my_access_token' conn = Faraday.new(url: 'http://my-mautic/api') do |f| f.request :oauth2, token f.request :url_encoded f.request :json f.response :json f.adapter Faraday.default_adapter end conn.headers['Authorization'] = "Bearer #{token}"

res = conn.get(‘contacts’)
puts res.status
#=> 500
puts res.reason_phrase
#=> Internal Server Error


Environments:
Code:
ruby 2.3.1 faraday 0.10.0 faraday_middleware 0.10.1

I am trying Mautic on Ruby. When I send a GET HTTP request to ‘http://my-mautic/api/contacts?access_token=my_access_token’ with a header ‘Authorization: Bearer my_access_token’, I get the Internal Server Error (500). The log (‘my-mautic/s/sysinfo’) says

[2017-07-27 09:31:48] mautic.CRITICAL: Uncaught PHP Exception OAuth2OAuth2AuthenticateException: "invalid_request" at /home/foo/bar/public_html/ma/vendor/friendsofsymfony/oauth2-php/lib/OAuth2.php line 570 {"exception":"[object] (OAuth2\OAuth2AuthenticateException(code: 0): invalid_request at /home/foobar/public_html/ma/vendor/friendsofsymfony/oauth2-php/lib/OAuth2.php:570)"} []

What I did is:

require 'faraday'; require 'faraday_middleware'
token = 'my_access_token'
conn = Faraday.new(url: 'http://my-mautic/api') do |f|
  f.request :oauth2, token
  f.request :url_encoded
  f.request :json
  f.response :json
  f.adapter Faraday.default_adapter
end
conn.headers['Authorization'] = "Bearer #{token}"

res = conn.get('contacts')
puts res.status
#=> 500
puts res.reason_phrase
#=> Internal Server Error

Environments:

ruby 2.3.1
faraday 0.10.0
faraday_middleware 0.10.1