hello,
goal: send a request that includes xml syntax via http post to
emaillabs’ api
problem: would like help in constructing the (xml) request properly
if one scrolls to the bottom of the emaillabs api overview
documentation here (http://www.emaillabs.com/email-marketing/api-
faq.html) under ‘What is an example of an API command?’,
notice the ‘type’ and ‘activity’ parameters. these, along with the
‘input’ parameter which is the xml ‘input from customer’ from
… through , are required according to the api
reference guide.
i’m using the net/http toolkit to try to post the request to emaillabs
so that i might receive some xml response back.
question: how would you incorporate the ‘type: record’, ‘activity:
query-data’, and ‘input: …’ parameters all
together in the (xml) request?
i tried to send everything together, but i suspect that this is not
correct.
in a ruby file, let’s say i have the following:
#!/usr/bin/env ruby
require ‘net/http’
require ‘rexml/document’
include REXML
target_url = ‘http://www.uptilt.com’
path = ‘/API/mailing_list.html’
http = Net::HTTP.new(target_url)
xml_request =<<EOF
Type:record
Activity:query-data
Input:
xml_response = http.post(path, xml_request)
puts xml_response.body
(the rexml is for me to parse the xml data once i am able to receive a
response.)
i get the following when running the ruby file:
400 Bad RequestBad Request
Your browser sent a request that this server could not
understand.
… so that i suspect my request isn’t constructed properly. i’ve also
tried using ‘END’ in lieu of ‘EOF’, and double quotes to hold the
data, but i’m guessing that the type/activity/input are the problem.
i’ve also tried to put them in xml tags, but that still produced the
same ‘response’. i’ve also ensured that the api security settings are
set up properly, and that i’m contacting the correct url location
(different from target_url, path, and in the emaillabs api faq
example).
how should my (xml) request be constructed? please advise.