FormPostAdd & Request:Body - WeOnlyDo Discussion board

FormPostAdd & Request:Body (General questions)

by Skc, Saturday, September 22, 2007, 01:36 (6272 days ago)

FormPost.Add allows me to format data to be sent to the server for update. I was able to use it successfully. However if I tried to set my own string and set it directly into Request.Body, it does not work.

Example (using the help sample)

(A) Successful
wodHttp1.Request.FormPost.Add Username , joe
wodHttp1.Request.FormPost.Add Password , joe
wodHttp1.Post http://www.weonlydo.com/HttpDLX/Demo/TestFormPost.asp

(B) Failed
wodHttp1.Hostname = www.weonlydo.com
wodHttp1.Request.Body = Username=joe&Password=joe
wodHttp1.Post /HttpDLX/Demo/TestFormPost.asp

Why is it that setting data direct into Request.Body does not work? Or Request.Body is not meant to be used in this way?

Thanks for any answer.

Re: FormPostAdd & Request:Body

by wodSupport, Saturday, September 22, 2007, 01:56 (6272 days ago) @ Skc

Skc,

did you set appropriate request header too? Look at Request.Headers.ToString in both cases - when we do formpost, and when you do it manually. What are you missing in your case?

Kreso

Re: FormPostAdd & Request:Body

by Skc, Monday, September 24, 2007, 10:21 (6270 days ago) @ wodSupport

Skc,

did you set appropriate request header too? Look at Request.Headers.ToString in both cases - when we do formpost, and when you do it manually. What are you missing in your case?

Kreso

No I did not set the request.headers. Do I need to? It is not stated in the Post() documentation.

the Request.Tostring of formpost return Content-Type: application/x-www-form-urlencoded .

I set this above string using Request.Headers.Add and it works!
Is there anything else that is required other than this?

Re: FormPostAdd & Request:Body

by wodDamir, Monday, September 24, 2007, 10:41 (6270 days ago) @ Skc

Hi Skc,

Great! I'm glad that works for you.

When you use FormPost, the wodHttpDLX adds headers automatically for. However, when you use it the way you did, it's unable to do that, and that's why it failed.

You don't need to set anything else. This should be sufficient.

Regards,
Damba