Created
February 27, 2018 21:08
-
-
Save digerata/7b232db76d0b1d3f8c3761d7078af192 to your computer and use it in GitHub Desktop.
This file contains 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 '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