Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

No data received by Server

21 views
Skip to first unread message

BWHUGHE

unread,
Jul 27, 2004, 12:43:46 PM7/27/04
to
I am executing a POST operation to a server and the server is indicating (using a page that echo's back the data it received) that it did not receive any data. I want to be sure I am understanding and using the winhttp API's correctly. I followed the example code in the API explanations. My code is as follows:

hRequest = WinHttpOpenRequest( hConnect,
L"POST",
L"/secure/echo.asp",
NULL,
WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
WINHTTP_FLAG_SECURE );

if ( hRequest )
{
bResults = WinHttpSendRequest( hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS,
0,
WINHTTP_NO_REQUEST_DATA,
0,
strlen( szCCData ),
0 );
if ( bResults )
{
bResults = WinHttpWriteData( hRequest,
szCCData,
strlen( szCCData ),
&dwBytesWritten );

I want to send the contents of szCCdata with the POST request. My understanding is that the contents of szCCData will be sent with WinHttpWriteData and not with the WinHttpSendRequest since I made the length of the optional data (dwOptionalData in API prototype) zero and the length of the data to be sent is greater than zero. I also tried changing the length of the optional data from 0 to strlen(szCCData) in the WinHttpSendRequest and commented out the WinHttpWriteData to see if the data would be sent just using the WinHttpSendRequest call (I don't know if that is correct) and I got the same result.

I have checked the data (szCCData) in memory before the calling the API's and the data is fine. I know I am connecting with the server because it is responding to my request but it indicates it received no data in the POST operation.

Alex Ostapenko

unread,
Jul 28, 2004, 6:10:06 AM7/28/04
to
Hello, BWHUGHE!
You wrote on Tue, 27 Jul 2004 09:43:46 -0700:

If you are going to POST form data you SHOULD explicitly specify content
type header.

With best regards,
Alex Ostapenko,
Helicon Tech.


BWHUGHE

unread,
Jul 28, 2004, 12:03:05 PM7/28/04
to
I don't know what form data is. My data is not coming from an http form or an http application it is coming directly from a credit card swipe reader. I am taking that data, formatting it and then posting it to an http server which will validate the credit card.
In talking with the service provider, my understanding is that I POST credit card data in an ASCII string in what looks like CSV format to a http server. However all their samples are browser based and I have no idea what is happening under the covers when the browser connects to the server. That is what I need to do using WinHttp. The only thing I know about http is what I have learned reading the WinHttp API information which to me is very confusing.

SAMPLE:
name="sjname" value="Jimmy SkipJack Test"
name="email" value="te...@skipjack.com"
name="Streetaddress" value="10549 Reading Rd" name="state" value="OH" name="city" value="Cincinnati"
name="zipcode" value="45241"
name="ordernumber" value="1"
name="accountnumber" value="4445999922225"
name="month" value="12"
name="year" value="04"
name="serialnumber" value="000594108441"
name="Transactionamount" value="1.00"
name="Orderstring" value="1~1~0.00~1~N~||"
name="shiptophone" value="8883688507"

Frank Schwieterman [MSFT]

unread,
Jul 28, 2004, 7:49:36 PM7/28/04
to
If you haven't already, that dwBytesWritten is what you expect after
calling WinHttpWriteData.

Can you do the request with IE and WinHttp without using SSL? If so, you
can use a network sniffer to see the difference between what IE is doing and
what your application is doing with WinHttp. I have a thread at
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&selm=OXPJMjAaDHA.1004%40TK2MSFTNGP12.phx.gbl
(thread title: Re: How to "see" a POST from IE
) which discusses some network sniffers available. Netmon is what I prefer
but its not always available.

The data you have is similar to but not the same as what form data formats
I've seen in the past, so I don't have a recommendation for what
content-type to use. That may or may not be the issue, hopefully you can
get a network sniff going.

"BWHUGHE" <BWH...@discussions.microsoft.com> wrote in message
news:14114864-102B-40D0...@microsoft.com...

BWHUGHE

unread,
Jul 29, 2004, 10:39:02 AM7/29/04
to
Problem solved, the format of the data I was sending incorrect. I changed the credit card data from CSV format to to "Form Submit" format (ordernumber=1&accountnumber=203465&month=12&year=2004) and it worked. Thanks to everyone who responded to my posts, they were very much appreciated.

Brian

0 new messages