# Class HTTPRequestPart

- [TopLevel.Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)
  - [dw.net.HTTPRequestPart](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.net.HTTPRequestPart.md)

This represents a part in a multi-part HTTP POST request.

A part always has a name and value. The value may be a String, Bytes, or the contents of a File.

A character encoding may be specified for any of these, and the content type and a file name may additionally be
specified for the Bytes and File types.

**Note:** when this class is used with sensitive data, be careful in persisting sensitive information.

## Property Summary

| Property                                                                                                                      | Description                                        |
| ----------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| [bytesValue](#bytesvalue): [Bytes](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Bytes.md) `(read-only)`      | Get the Bytes value of the part.                   |
| [contentType](#contenttype): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)` | Returns the content type of this part.             |
| [encoding](#encoding): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`       | Get the charset to be used to encode the string.   |
| [fileName](#filename): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`       | Get the file name to use when sending a file part. |
| [fileValue](#filevalue): [File](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.io.File.md) `(read-only)`            | Get the file value of the part.                    |
| [name](#name): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`               | Get the name of the part.                          |
| [stringValue](#stringvalue): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)` | Get the string value of the part.                  |

## Constructor Summary

| Constructor                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Description                                                    |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| [HTTPRequestPart](#httprequestpartstring-string)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))                                                                                                                                                                                                                                                                              | Construct a part representing a simple string name/value pair. |
| [HTTPRequestPart](#httprequestpartstring-string-string)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))                                                                                                                                                                                   | Construct a part representing a simple string name/value pair. |
| [HTTPRequestPart](#httprequestpartstring-file)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [File](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.io.File.md))                                                                                                                                                                                                                                                                                       | Construct a part representing a name/File pair.                |
| [HTTPRequestPart](#httprequestpartstring-bytes)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [Bytes](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Bytes.md))                                                                                                                                                                                                                                                                                  | Construct a part representing a name/bytes pair.               |
| [HTTPRequestPart](#httprequestpartstring-bytes-string-string-string)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [Bytes](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Bytes.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)) | Construct a part representing a name/File pair.                |
| [HTTPRequestPart](#httprequestpartstring-file-string-string)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [File](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.io.File.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))                                                                                                 | Construct a part representing a name/File pair.                |
| [HTTPRequestPart](#httprequestpartstring-file-string-string-string)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [File](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.io.File.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))      | Construct a part representing a name/File pair.                |

## Method Summary

| Method                                                                                                             | Description                                        |
| ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------- |
| [getBytesValue](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.net.HTTPRequestPart.md#getbytesvalue)()   | Get the Bytes value of the part.                   |
| [getContentType](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.net.HTTPRequestPart.md#getcontenttype)() | Returns the content type of this part.             |
| [getEncoding](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.net.HTTPRequestPart.md#getencoding)()       | Get the charset to be used to encode the string.   |
| [getFileName](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.net.HTTPRequestPart.md#getfilename)()       | Get the file name to use when sending a file part. |
| [getFileValue](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.net.HTTPRequestPart.md#getfilevalue)()     | Get the file value of the part.                    |
| [getName](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.net.HTTPRequestPart.md#getname)()               | Get the name of the part.                          |
| [getStringValue](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.net.HTTPRequestPart.md#getstringvalue)() | Get the string value of the part.                  |

### Methods inherited from class Object

[assign](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#assignobject-object), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject-object), [defineProperties](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertiesobject-object), [defineProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertyobject-object-object), [entries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#entriesobject), [freeze](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#freezeobject), [fromEntries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#fromentriesiterable), [getOwnPropertyDescriptor](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertydescriptorobject-object), [getOwnPropertyNames](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertynamesobject), [getOwnPropertySymbols](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertysymbolsobject), [getPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getprototypeofobject), [hasOwnProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#hasownpropertystring), [is](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isobject-object), [isExtensible](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isextensibleobject), [isFrozen](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isfrozenobject), [isPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isprototypeofobject), [isSealed](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#issealedobject), [keys](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#keysobject), [preventExtensions](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#preventextensionsobject), [propertyIsEnumerable](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#propertyisenumerablestring), [seal](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#sealobject), [setPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#setprototypeofobject-object), [toLocaleString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tolocalestring), [toString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tostring), [valueOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valueof), [values](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valuesobject)

## Property Details

### bytesValue

- bytesValue: [Bytes](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Bytes.md) `(read-only)`
  - : Get the Bytes value of the part.

***

### contentType

- contentType: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Returns the content type of this part.

***

### encoding

- encoding: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Get the charset to be used to encode the string.

***

### fileName

- fileName: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Get the file name to use when sending a file part.

***

### fileValue

- fileValue: [File](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.io.File.md) `(read-only)`
  - : Get the file value of the part.

***

### name

- name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Get the name of the part.

***

### stringValue

- stringValue: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Get the string value of the part.

***

## Constructor Details

### HTTPRequestPart(String, String)

- HTTPRequestPart(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), value: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))
  - : Construct a part representing a simple string name/value pair. The HTTP
    message uses "US-ASCII" as the default character set for the part.

    **Parameters:**

    - name - The name of the part.
    - value - The string to post.

***

### HTTPRequestPart(String, String, String)

- HTTPRequestPart(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), value: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), encoding: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))
  - : Construct a part representing a simple string name/value pair. The HTTP
    message uses the specified encoding or "US-ASCII" if null is passed
    for the part.

    **Parameters:**

    - name - The name of the part.
    - value - The string to post.
    - encoding - The charset to be used to encode the string, if null the             default is used.

***

### HTTPRequestPart(String, File)

- HTTPRequestPart(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), file: [File](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.io.File.md))
  - : Construct a part representing a name/File pair. The HTTP message will use
    "application/octet-stream" as the content type and "ISO-8859-1" as the character
    set for the part.

    **Parameters:**

    - name - The name of the file part
    - file - The file to post

***

### HTTPRequestPart(String, Bytes)

- HTTPRequestPart(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), data: [Bytes](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Bytes.md))
  - : Construct a part representing a name/bytes pair. The HTTP message will use
    "application/octet-stream" as the content type without a character set.

    **Parameters:**

    - name - The name of the file part
    - data - The bytes to post

***

### HTTPRequestPart(String, Bytes, String, String, String)

- HTTPRequestPart(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), data: [Bytes](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Bytes.md), contentType: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), encoding: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), fileName: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))
  - : Construct a part representing a name/File pair.

    - If both contentType and encoding are null, then the part will be defaulted to use "application/octet-stream"  as the content-type without an encoding.    - If only the encoding is null, then the contentType will be used without an encoding.        - If only the contentType is null, then it will be defaulted to "text/plain".

    **Parameters:**

    - name - The name of the file part
    - data - The bytes to post
    - contentType - The content type for this part, if null or blank the default is used.
    - encoding - the charset encoding for this part, if null or blank the default is used.
    - fileName - The file name to use in the Mime header, or null to not use one.

***

### HTTPRequestPart(String, File, String, String)

- HTTPRequestPart(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), file: [File](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.io.File.md), contentType: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), encoding: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))
  - : Construct a part representing a name/File pair.

    - If both contentType and encoding are null, then the part will be defaulted to use "application/octet-stream"  as the content-type and "ISO-8859-1" as the encoding.    - If only the encoding is null, then the contentType will be used without an encoding.        - If only the contentType is null, then it will be defaulted to "text/plain".

    **Parameters:**

    - name - The name of the file part
    - file - The file to post
    - contentType - The content type for this part, if null or blank the default is used.
    - encoding - the charset encoding for this part, if null or blank the default is used

***

### HTTPRequestPart(String, File, String, String, String)

- HTTPRequestPart(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), file: [File](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.io.File.md), contentType: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), encoding: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), fileName: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))
  - : Construct a part representing a name/File pair.

    - If both contentType and encoding are null, then the part will be defaulted to use "application/octet-stream"  as the content-type and "ISO-8859-1" as the encoding.    - If only the encoding is null, then the contentType will be used without an encoding.        - If only the contentType is null, then it will be defaulted to "text/plain".

    **Parameters:**

    - name - The name of the file part
    - file - The file to post
    - contentType - The content type for this part, if null or blank the default is used.
    - encoding - the charset encoding for this part, if null or blank the default is used
    - fileName - The file name to use in the Mime header, or null to use the name of the given file.

***

## Method Details

### getBytesValue()

- getBytesValue(): [Bytes](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Bytes.md)
  - : Get the Bytes value of the part.

    **Returns:**

    - The Bytes value, or null if this part is not a Bytes part.

***

### getContentType()

- getContentType(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Returns the content type of this part.

    **Returns:**

    - The content type, or null if content type was not specified.

***

### getEncoding()

- getEncoding(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Get the charset to be used to encode the string.

    **Returns:**

    - The charset, or null if charset was not specified.

***

### getFileName()

- getFileName(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Get the file name to use when sending a file part.

    **Returns:**

    - File name to use in the Mime header, or null for default behavior.

***

### getFileValue()

- getFileValue(): [File](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.io.File.md)
  - : Get the file value of the part.

    **Returns:**

    - The file value, or null if this part is not a file part.

***

### getName()

- getName(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Get the name of the part.

    **Returns:**

    - The part name, never null.

***

### getStringValue()

- getStringValue(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Get the string value of the part.

    **Returns:**

    - The string value, or null if this part is not a string part.

***
