Skip to content

Instantly share code, notes, and snippets.

@digerata
Created February 27, 2018 21:08
Show Gist options
  • Save digerata/7b232db76d0b1d3f8c3761d7078af192 to your computer and use it in GitHub Desktop.
Save digerata/7b232db76d0b1d3f8c3761d7078af192 to your computer and use it in GitHub Desktop.
require 'uri'
require 'net/http'
class ExampleController < ApplicationController
def test_smartline
url = URI("https://smartlinedesign.quickbase.com/db/bngiubrjh?a=API_ImportFromCSV&ticket=9_bnhq59q6c_b3nhzn_irxj_a_-b_dgzffhkd5iim4bdnppgpdbs78vct64nqkdf97a28cfbqezkda565cd_jd3u8z")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
req = Net::HTTP::Post.new(url)
req["content-type"] = 'application/xml'
req["cache-control"] = 'no-cache'
req["postman-token"] = '34ffbc0f-a06f-9329-954d-a3b25614edde'
xml = %{
<?xml version="1.0"?>
<qdbapi>
<ticket>9_bng68ceik_b3nhzn_irxj_a_-b_de9vcbg7rapssdct6x3ib7je3cgdve42e4c3nihxwb3jrzeecmagews_ifyvub</ticket>
<apptoken>dwckwpndiyr9nebq9bhktibd49c</apptoken>
<records_csv><![CDATA[
Michigan, Ann Arbor-#{DateTime.now}
]]></records_csv>
<clist>6.8</clist>
<clist_output>6.8</clist_output>
</qdbapi>
}
puts "Sending XML:\n#{xml}"
req.body = xml
resp = http.request(req)
ap resp
raise "QuickBase error: #{resp["quickbase-errtext"]}" if resp["quickbase-errcode"].to_i > 0
head :ok
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment