goddamnyouryan
goddamnyouryan

Reputation: 6896

posting xml file for api using rails

I am trying to post an xml file to the dealmapenter link description here api using an xml file I built with builder in rails (though this should apply to any xml POST request).

The XML file I am trying to send can be found here:

http://www.frugle.me/frugles/25-10-off-purchase/dealmap.xml

and the address I am trying to post to here:

http://api.thedealmap.com/deals/?key=0-2304664-634434226955110000

I am attempting to do it with curl using either/both:

curl -X POST -d -v http://www.frugle.me/frugles/25-10-off-purchase/dealmap.xml http://api.thedealmap.com/deals/?key=0-2304664-634434226955110000

or

curl -d -v http://www.frugle.me/frugles/25-10-off-purchase/dealmap.xml http://api.thedealmap.com/deals/?key=0-2304664-634434226955110000

but sometimes I get a 404 error on my end, and other times I get a 500 error on dealmaps end like so:

* About to connect() to api.thdealmap.com port 80 (#0) 
*   Trying 173.227.66.251... connected 
* Connected to api.thdealmap.com (173.227.66.251) port 80 (#0) 
> POST /deals/?key=0-2304664-634434226955110000 HTTP/1.1 
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3 
> Host: api.thdealmap.com 
> Accept: */* 
> Content-Length: 65 
> Content-Type: application/x-www-form-urlencoded 

< HTTP/1.1 500 Internal Server Error 
< Connection: close 
< Date: Sun, 12 Jun 2011 05:04:42 GMT 
< Server: Microsoft-IIS/6.0 
< Content-Language: en-US 
< Content-Type: text/html 
< 
* Closing connection #0 

Am I going about this all wrong? Is there a standard way to be doing this? I am having trouble finding any information in general on the internet about such actions, though it seems like they would be commonplace.

Any help you could give would be much appreciated!

Upvotes: 0

Views: 587

Answers (1)

eggie5
eggie5

Reputation: 1960

What you're doing is not posting the xml file here http://www.frugle.me/frugles/25-10-off-purchase/dealmap.xml you are posting this literal string "http://www.frugle.me/frugles/25-10-off-purchase/dealmap.xml" to http://api.thedealmap.com/deals/?key=0-2304664-634434226955110000.

Try this to post the xml:

curl -X POST -v --data-ascii @xmlfile.xml  http://api.thedealmap.com/deals/?key=0-2304664-634434226955110000
* About to connect() to api.thedealmap.com port 80 (#0)
*   Trying 50.19.80.24... connected
* Connected to api.thedealmap.com (50.19.80.24) port 80 (#0)
> POST /deals/?key=0-2304664-634434226955110000 HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
> Host: api.thedealmap.com
> Accept: */*
> Content-Length: 1271
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
> 
< HTTP/1.1 100 Continue
< HTTP/1.1 400 Bad Request
< Cache-Control: no-cache
< Content-Type: text/html
< Date: Mon, 27 Jun 2011 06:39:54 GMT
< Server: Microsoft-IIS/7.0
< Set-Cookie: ASP.NET_SessionId=wo1i2h45dprmkqec41sl4v55; path=/; HttpOnly
< X-AspNet-Version: 2.0.50727
< Content-Length: 1165
< Connection: keep-alive
< 
<?xml version="1.0" encoding="utf-8"?><HTML><HEAD><STYLE type="text/css">#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE>
<TITLE>Request Error</TITLE></HEAD><BODY>
<DIV id="content">
<P class="heading1">Request Error</P>
<BR/>
<P class="intro">The server encountered an error processing the request. See server logs for more details.</P>
<P class="intro"></P>
</DIV>
* Connection #0 to host api.thedealmap.com left intact
* Closing connection #0

Upvotes: 2

Related Questions