Skip to content

Instantly share code, notes, and snippets.

@tbalthazar
Last active August 29, 2015 14:03
Show Gist options
  • Save tbalthazar/05237af3eaf1ebba951d to your computer and use it in GitHub Desktop.
Save tbalthazar/05237af3eaf1ebba951d to your computer and use it in GitHub Desktop.
Harvest API bug
#!/usr/bin/env ruby
# Create an invoice via the Web UI, and paste its ID here
# Also, fill in the SUBDOMAIN, USERNAME and PASSWORD values.
INVOICE_ID = ''
SUBDOMAIN = ''
USERNAME = ''
PASSWORD = ''
def curl_cmd(message, action)
`curl -s -H \"Content-Type: application/json\" -H \"Accept: application/json\" -d '{\"invoice_message\":{\"body\":\"#{message}\"}}' -u \"#{USERNAME}:#{PASSWORD}\" https://#{SUBDOMAIN}.harvestapp.com/invoices/#{INVOICE_ID}/messages/#{action}`
end
# mark invoice as sent
curl_cmd('sent message', 'mark_as_sent')
# mark invoice as closed
curl_cmd('closed message', 'mark_as_closed')
# reopen invoice
curl_cmd('reopen message', 're_open')
# mark invoice as draft
curl_cmd('draft message', 'mark_as_draft')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment