Encoding Property  
 

Gets and sets the content encoding type.

Syntax

object.Encoding = [type ]

Remarks

The Encoding property explicitly sets the type of encoding used when optional parameter data is submitted with a request for a resource. By default, data is URL encoded and the content type will be designated as application/x-www-form-urlencoded. The following encoding types are supported:

Value Constant Description
0 httpEncodingNone No encoding will be applied to the content of a request and no default content type will be specified. This encoding type should be used with REST APIs and other services which expect XML or JSON request payloads.
1 httpEncodingURL Non-printable and extended ASCII characters will be encoded so they can be safely used with URLs and form data. Encoded characters will be represented by a percent symbol prefix, followed by a two digit hexadecimal value which represents the ASCII character code. This encoding is typically used with web services which process HTML form data.
2 httpEncodingXML This encoding is identical to URL encoding, except spaces are not encoded. It is used with legacy web services which expect form data in an XML format and cannot process encoded whitespace. This encoding should not be specified for services which use REST APIs.

The Encoding property explicitly sets the type of encoding used when optional parameter data is submitted with a request for a resource. If an encoding type is specified, and the content type for the request payload has not been defined, it will default to application/x-www-form-urlencoded.

When submitting a JSON or XML request to a service using a REST API, your application should use httpEncodingNone and set the appropriate content type for the request payload. The httpEncodingXml encoding type should only be used if the server expects URL encoded form data. The PostJson and PostXml methods will automatically set the correct encoding and content type for those requests.

If an application specifies httpEncodingNone, parameter data is not encoded and no content type header will created by default. The client application can specify the content type by calling the SetHeader method.

Data Type

Integer (Int32)

See Also

HeaderField Property, HeaderValue Property, PostData Method, PostJson Method, PostXml Method, SetHeader Method