Created
June 8, 2013 21:38
-
-
Save rsalmond/5736708 to your computer and use it in GitHub Desktop.
Create a ticket with a file attachment through the Freshdesk API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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