[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HTTPAPI 1.11 pre-release - no data received with POST



You are awesome, thanks so much!
Once again that did the trick....
I had tried all kinds of things coding 'application/x-www-form-urlencoded' onto the front of my XML data etc.
 
Thanks, Eric

>>> sk@xxxxxxxxxxxxxxxx 07/12/05 1:42 PM >>>
Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>

Hi Eric,

> The bad news is my Vendor tells me that don't receive any of it with the
> "post" method? They have a "debug" site that I can "post" to it returns
> the following message to me...
[SNIP]

You sent me your code off-list, and it contains the following statement:

      c                   eval      rc = http_url_post(
      c                             'http://xxxx.xxxxxx.com/API/' +
      c                                  'mailing_list.html'
      c                             : myPointer
      c                             : dataSize
      c                             : '/tmp/testpost.xml')

That statement is okay, except that it doesn't tell the web server what
type of content you're sending.  That's not a problem with a GET request
because the data type is always the same -- it's always a URL encoded web
form, since that's really the only thing that you CAN send with GET.

HTTPAPI has a "default" content-type that's set in the CONFIG_H source
member. That default is "text/xml" meaning that you are uploading an XML
document to the server.

Here's where it gets confusing:  Although your document IS an XML
document, it's not sent as one.  Instead, it's sent as a URL encoded web
form. So, technically "text/xml" is wrong for your document, even though
it's XML.  Instead, it needs to be sent as
"application/x-www-form-urlencoded".

Now, that's not a problem in my EXAMPLE2 because my web server is stupid.
It ignores the content type, and just assumes that whatever you send is
valid for it's purposes.  This demo site is smarter. It will ignore data
that's not of the type it's expecting.

Anyway, it's pretty easy to fix. Just change your HTTP_url_post() call to
look like this:

      c                   eval      rc = http_url_post(
      c                             'http://xxxx.xxxxxx.com/API/' +
      c                                  'mailing_list.html'
      c                             : myPointer
      c                             : dataSize
      c                             : '/tmp/testpost.xml'
      c                             : HTTP_TIMEOUT
      c                             : HTTP_USERAGENT
      c                             : 'application/x-www-form-urlencoded')

The HTTP_TIMEOUT is the default value for timeouts in HTTPAPI. You can
pass that value any time you want to use the default.  Likewise,
HTTP_USERAGENT is the default value for the user-agent parameter.

Then, in the last parameter, I'm telling it that the content type is a
URL-encoded web form. That will cause the server to interpret it properly.
I tested it with your code, and it seemed to solve the problem.

Let us know if it works from your machine as well.

Thanks!
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------