Skip to content

Instantly share code, notes, and snippets.

@rsalmond
Created June 8, 2013 21:38
Show Gist options
  • Select an option

  • Save rsalmond/5736708 to your computer and use it in GitHub Desktop.

Select an option

Save rsalmond/5736708 to your computer and use it in GitHub Desktop.
Create a ticket with a file attachment through the Freshdesk API
require "rubygems"
require "rest_client"
require "json"
site = RestClient::Resource.new("http://yourcompany.domain.com/helpdesk/tickets.json","[email protected]","test")
#custom ticket fields should be added as <ticket_field_name>_<account_id>
data={:description=>"Test ticket creation with attachments",:subject=>"new ticket sample",:email=>"[email protected]",:custom_field=>{:department_category_16699=>"Information Technology"},"attachments"=>{''=>[{:resource=>File.open("tommy1.jpg")},{:resource=>File.open("tommy.jpg")}]}}
response = site.post({:helpdesk_ticket=> data},:content_type=>"application/json")
puts "response: #{response.code} \n #{response.body}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment