Skip to content

Instantly share code, notes, and snippets.

@amw amw/Gemfile
Created Nov 5, 2012

Embed
What would you like to do?
Issues with zendesk api and multipart in rails app
... cutting out user request ...
post https://mysite.zendesk.com/api/v2/tickets
Accept: "application/json"
Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
User-Agent: "ZendeskAPI API 0.1.10"
Authorization: "Basic BASE64CODE=="
{:ticket=>#<Hashie::Mash comment=#<Hashie::Mash value="This is a test"> description="Testign zendesk API" priority="urgent" requester=#<Hashie::Mash email="someone@gmail.com" name="Someone"> subject="Test Ticket" submitter_id=1234 tags=["bug_report"]>}
source 'https://rubygems.org'
gem 'bundler', '~> 1.0'
gem 'railties', '~> 3.2.6'
gem 'actionmailer'
gem 'actionpack'
gem 'activeresource'
gem 'activesupport'
gem "mongoid", "~> 3.0.6"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'state_machine'
gem 'ruby-filemagic'
gem "mini_magick"
gem 'cancan', '~> 1.6.8'
gem 'aws-sdk', '~> 1.6.3'
gem 'ruby-aws', '~> 1.5.0', git: 'git://github.com/amw/ruby-aws.git'
gem 'devise', '~> 2.1.0'
gem 'delayed_job_mongoid', '~> 2.0.0'
gem 'delayed_job', '~> 3.0.3'
gem 'daemons'
gem 'dj_mon'
gem 'parallel'
gem 'unicorn'
gem 'zendesk_api'
gem 'patron'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Deploy with Capistrano
gem 'capistrano'
# To use debugger
# gem 'debugger'
group :development do
gem 'capistrano-unicorn', :require => false,
git: 'git://github.com/sosedoff/capistrano-unicorn.git'
end
group :data_import do
gem 'mysql2'
end
GIT
remote: git://github.com/amw/ruby-aws.git
revision: 101ad6f4944ebe2e07592a99de07ba874a0102e0
specs:
ruby-aws (1.5.0)
highline (>= 1.2.7)
nokogiri (>= 1.4)
GIT
remote: git://github.com/sosedoff/capistrano-unicorn.git
revision: bafc12cd8235307d30b5c85259914d17c5ece2d3
specs:
capistrano-unicorn (0.1.6)
capistrano
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.8)
actionpack (= 3.2.8)
mail (~> 2.4.4)
actionpack (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
activerecord (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
aws-sdk (1.6.5)
httparty (~> 0.7)
json (~> 1.4)
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
bcrypt-ruby (3.0.1)
builder (3.0.4)
cancan (1.6.8)
capistrano (2.13.3)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.3)
daemons (1.1.9)
delayed_job (3.0.3)
activesupport (~> 3.0)
delayed_job_mongoid (2.0.0)
delayed_job (~> 3.0)
mongoid (~> 3.0)
devise (2.1.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
dj_mon (1.0.0)
haml (~> 3.1)
rails (~> 3.1)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
faraday (0.8.4)
multipart-post (~> 1.1)
faraday_middleware (0.9.0)
faraday (>= 0.7.4, < 0.9)
haml (3.1.7)
hashie (1.2.0)
highline (1.6.14)
hike (1.2.1)
httparty (0.8.3)
multi_json (~> 1.0)
multi_xml
i18n (0.6.1)
inflection (1.0.0)
journey (1.0.4)
jquery-rails (2.1.1)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
json (1.7.5)
kgio (2.7.4)
libv8 (3.3.10.4)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.19)
mini_magick (3.4)
subexec (~> 0.2.1)
mongoid (3.0.10)
activemodel (~> 3.1)
moped (~> 1.1)
origin (~> 1.0)
tzinfo (~> 0.3.22)
moped (1.2.7)
multi_json (1.3.6)
multi_xml (0.5.1)
multipart-post (1.1.5)
mysql2 (0.3.11)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.5.2)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
nokogiri (1.5.5)
origin (1.0.10)
orm_adapter (0.4.0)
parallel (0.5.18)
patron (0.4.18)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.8)
actionmailer (= 3.2.8)
actionpack (= 3.2.8)
activerecord (= 3.2.8)
activeresource (= 3.2.8)
activesupport (= 3.2.8)
bundler (~> 1.0)
railties (= 3.2.8)
railties (3.2.8)
actionpack (= 3.2.8)
activesupport (= 3.2.8)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
raindrops (0.10.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
ruby-filemagic (0.4.2)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
state_machine (1.1.2)
subexec (0.2.2)
therubyracer (0.10.2)
libv8 (~> 3.3.10)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.34)
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
unicorn (4.3.1)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
uuidtools (2.1.3)
warden (1.2.1)
rack (>= 1.0)
zendesk_api (0.1.10)
faraday (>= 0.8.0)
faraday_middleware (>= 0.8.7)
hashie
inflection
json
mime-types
multipart-post
PLATFORMS
ruby
DEPENDENCIES
actionmailer
actionpack
activeresource
activesupport
aws-sdk (~> 1.6.3)
bundler (~> 1.0)
cancan (~> 1.6.8)
capistrano
capistrano-unicorn!
coffee-rails (~> 3.2.1)
daemons
delayed_job (~> 3.0.3)
delayed_job_mongoid (~> 2.0.0)
devise (~> 2.1.0)
dj_mon
jquery-rails
mini_magick
mongoid (~> 3.0.6)
mysql2
parallel
patron
railties (~> 3.2.6)
ruby-aws (~> 1.5.0)!
ruby-filemagic
sass-rails (~> 3.2.3)
state_machine
therubyracer
uglifier (>= 1.0.3)
unicorn
zendesk_api
$rails r zentest.rb
/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/multipart-post-1.1.5/lib/parts.rb:52:in `initialize': undefined method `original_filename' for "Test Ticket":String (NoMethodError)
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/multipart-post-1.1.5/lib/parts.rb:11:in `new'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/multipart-post-1.1.5/lib/parts.rb:11:in `new'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:37:in `block in create_multipart'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:57:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:57:in `block in process_params'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:47:in `each'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:47:in `inject'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:47:in `process_params'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:55:in `block in process_params'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:47:in `each'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:47:in `inject'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:47:in `process_params'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:36:in `create_multipart'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:11:in `block in call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/url_encoded.rb:20:in `match_content_type'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:7:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/zendesk_api-0.1.10/lib/zendesk_api/middleware/request/upload.rb:16:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/zendesk_api-0.1.10/lib/zendesk_api/middleware/request/etag_cache.rb:18:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday_middleware-0.9.0/lib/faraday_middleware/response_middleware.rb:30:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday_middleware-0.9.0/lib/faraday_middleware/response_middleware.rb:30:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday_middleware-0.9.0/lib/faraday_middleware/response_middleware.rb:30:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/zendesk_api-0.1.10/lib/zendesk_api/middleware/response/parse_iso_dates.rb:11:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/response.rb:8:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/zendesk_api-0.1.10/lib/zendesk_api/middleware/response/logger.rb:20:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/response.rb:8:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/response.rb:8:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/request/authorization.rb:36:in `call'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/connection.rb:226:in `run_request'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.4/lib/faraday/connection.rb:99:in `post'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/zendesk_api-0.1.10/lib/zendesk_api/actions.rb:22:in `save'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/zendesk_api-0.1.10/lib/zendesk_api/rescue.rb:28:in `block (2 levels) in rescue_client_error'
from zentest.rb:23:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/runner.rb:51:in `eval'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/runner.rb:51:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:64:in `require'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:64:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
require "zendesk_api"
require "faraday"
client = ZendeskAPI::Client.new do |config|
config.url = "https://mysite.zendesk.com/api/v2"
config.username = "myemail@example.net"
config.password = "mypassword"
config.retry = true
config.logger = Rails.logger
config.adapter = :patron
end
user = client.current_user
ticket = ZendeskAPI::Ticket.new(client,
subject: "Test Ticket",
description: "Testign zendesk API",
comment: {:value => "This is a test" },
requester: {email: "someone@gmail.com", name: "Someone"},
:submitter_id => user.id,
priority: "urgent",
tags: ["bug_report"])
ticket.save
puts ticket.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.