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’s httpBody is set, and a value is set for the HTTP header field Content-Type.

    Throws

    MultipartFormDataEncodingError if any keys or values in parameters are not entirely in encoding.

    Note

    The default httpMethod is GET, and GET requests do not typically have a response body. Remember to set the httpMethod 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.