Top  | Previous | Next

system.net.httpPost

Description

Retrieves the document at the given URL using the HTTP POST protocol. If a parameter dictionary argument is specified, the entries in the dictionary will encoded in "application/x-www-form-urlencoded" format, and then posted. You can post arbitrary data as well, but you'll need to specify the MIME type. The document is then returned as a string.

Syntax

system.net.httpPost(url, postParams)

Parameters

String url - The URL to post to.

PyDictionary postParams - A dictionary of name: value key pairs to use as the post data.

Returns

String - The content returned for the POST operation.

Scope

All

system.net.httpPost(url, contentType, postData)

Parameters

String url - The URL to post to.

String contentType - The MIME type to use in the HTTP "Content-type" header.

String postData - The raw data to post via HTTP.

Returns

String - The content returned for the POST operation.

Scope

All

Examples

Example 1:

 

# This code posts a name (first and last) to the post testing page at

# "http://www.snee.com/xml/crud/posttest.cgi", and returns the resulting page as a string.

page = system.net.httpPost("http://www.snee.com/xml/crud/posttest.cgi", {"fname":"Billy""lname":"Bob"})

print page

 

Example 2:

 

# This code sends an XML message to a hypothetical URL.

message = "<MyMessage><MyElement>here is the element</MyElement></MyMessage>"

system.net.httpPost("http://www.posttome.xyz/posthere""text/xml", message)