Skip to main content
Version: 7.9

system.net.httpPost

This function is used in Python Scripting.

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.

Keep in mind that JRE proxy settings will influence how these functions conduct their network activities. When using a non-bundled JRE, this is typically set via the Java Control Panel.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax #1

system.net.httpPost(url, postParams)

Parameters

TypeParameterDescription
StringurlThe URL to post to.
PyDictionarypostParamsA dictionary of name: value key pairs to use as the post data.

Returns

String - The content returned for the POST operation.

Scope

All

Syntax #2

system.net.httpPost(url, contentType, postData, connectTimeout, readTimeout, username, password, headerValues, bypassCertValidation, throwOnError)

Parameters

TypeParameterDescription
StringurlThe URL to post to.
StringcontentType[Optional]The MIME type to use in the HTTP "Content-type" header.
StringpostDataThe raw data to post via HTTP.
IntegerconnectTimeoutThe timeout for connecting to the url. In milliseconds. Default is 10,000.
IntegerreadTimeoutThe read timeout for the get operation. In milliseconds. Default is 60,000.
StringusernameIf specified, the call will attempt to authenticate with basic HTTP authentication.
StringpasswordThe password used for basic http authentication, if the username parameter is also present.
PyDictionaryheaderValues[Optional] A dictionary of name/value pairs that will be set in the http header.
BooleanbypassCertValidation[Optional] If the target address is an HTTPS address, and this parameter is True,the system will bypass all SSL certificate validation. This is not recommended, though is sometimes necessary for self-signed certificates.
BooleanthrowOnError[Optional] Set to False if you wish to get the error body rather than a python exception if the POST request returns an error code (non-200 responsive). Default is True.

Returns

String - The content returned for the POST operation.

Scope

All

If you are using JSON, check out the system.util.jsonEncode and system.util.jsonDecode.

Code Examples

Code Snippet
# 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
Code Snippet
# 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)