Categories: Symbian C++ | Code Examples | How To | Networking | HTTP
This page was last modified 06:53, 25 September 2007.
Constructing HTTP POST Url parameters
From Forum Nokia Wiki
This article shows how to send parameters along with the URL in an HTTP POST.
Consider that a web server needs some parameters for e.g.
// URL for POST request. _LIT8(KPostUri, "http://mysite.net/test/update");
The following parameters need to be posted to the above URL, username/password
_LIT8(KPostParamName1, "username"); _LIT8(KPostParamName2, "password");
This can be done using the HTTP Client with form encoder using class CHTTPFormEncoder
//Construction iFormEncoder = CHTTPFormEncoder::NewL();
In the POST request:
void CHTTPExampleEngine::PostRequestL(const TDesC& aUsername,const TDesC& aPassword) { TBuf8<50> iTemp; TBuf8<50> iTemp2; iTemp.Copy(aUsername); iTemp2.Copy(KPostParamName1); iFormEncoder->AddFieldL(iTemp2,iTemp); iTemp.Copy(aPassword); iTemp2.Copy(KPostParamName2); iFormEncoder->AddFieldL(iTemp2,iTemp); .... .... iTransaction.Request().SetBody(*iFormEncoder); iTransaction.SubmitL(); }
Remember the following:
_LIT8(KUserAgent, "HTTPExample (1.0)"); // Name of this client app _LIT8(KAccept, "text/*");// Accept any (but only) text content _LIT8(KPostParamName1, "username");//Name of the parameter in a POST request _LIT8(KPostParamName2, "password"); _LIT8(KPostContentType, "text/*");//Content type sent in a POST request _LIT8(KContentTypeForm, "application/x-www-form-urlencoded\0");
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is the XML parser of JSR 172 in Symbian 9.2 flawed? | t-k-s | General Discussion | 7 | 2008-01-21 15:27 |
| Problem in shifting view | ash_21 | General Symbian C++ | 26 | 2007-09-11 05:52 |
| mms notification to 7210 | gulyasa | General Messaging | 1 | 2003-10-24 13:59 |
| Nokia n65/90 get params | RamiX | Mobile Java General | 1 | 2008-01-21 17:00 |
| i cann't able to download 3gp file using j2me app but from mobile browser ? | ajuj20 | Mobile Java Networking & Messaging & Security | 1 | 2007-06-25 11:13 |
