URLRequest
extension URLRequest
-
Encodes the given parameters into the request.
Declaration
Swift
public mutating func setUrlEncodedFormData(_ parameters: [String : String])
Parameters
parameters
The parameters to be encoded into the URLRequest.
-
Configures the URL request for
multipart/form-data
. The request’shttpBody
is set, and a value is set for the HTTP header fieldContent-Type
.Throws
MultipartFormDataEncodingError
if any keys or values inparameters
are not entirely inencoding
.Note
The default
httpMethod
isGET
, andGET
requests do not typically have a response body. Remember to set thehttpMethod
to e.g.POST
before sending the request.Declaration
Swift
public mutating func setMultipartFormData(_ parameters: [String : String], encoding: String.Encoding) throws
Parameters
parameters
The form data to set.
encoding
The encoding to use for the keys and values.