Documentation > CMS Template API Library > Util > PostHttp(String,PostHttpParams)
PostHttp
Sends a POST request to the provided URL. Use the PostHttpParams object to set the Post Data as well as optional values for timeout, headers, and content-type.
public CrownPeak.CMSAPI.PostHttpResponse PostHttp(String,PostHttpParams)
Returns
A PostHttpResponse object which contains the response text as well as various meta data about the POST request. A Status Code of -900 is returned if a connection to the server could not be established.
Parameters
| Name | Description | Type |
|---|---|---|
| url | The URL. | System.String |
| postHttpParams | The HTTP params. | CrownPeak.CMSAPI.PostHttpParams |
Code Example
C#
Sample:
string url = "http://www.crownpeak.com";
PostHttpParams postHttpParams = new PostHttpParams();
postHttpParams.TimeOut = 20;
postHttpParams.AddHeader("Accept-Encoding: gzip,deflate");
postHttpParams.ContentType = "Content-Type: text/xml";
PostHttpResponse response = Util.PostHttp(url, postHttpParams);
if(response.StatusCode >= 200 && response.StatusCode < 300)
{
Out.WriteLine(response.ResponseText);
}