I'm creating a REST API from scratch for a preexisting iOS app whose API source code is, for all intents and purposes, no longer available. This means I'm analyzing how each endpoint expects requests sent to it to be formatted. One of those endpoints is communicated with via Alamofire's Session.upload(multipartFormData:to:method:headers:)
.
The multipartFormData
is a closure parameter that is passed a MultipartFormData
object, permits the consumer to mutate it (add key-value pairs to it in this case), and then return it from the closure.
My question is how does that addition of these key-value pairs to the MultipartFormData
affect the format of the HTTP request. Up until this point every .post
method has been passed a Dictionary<String, Any>
and JSON has been specified as the encoding, so it has been straightforward to assess how the payload is uploaded (a single JSON object with a parameter for each entry in the dictionary). But it is not so straightforward with this Session.upload(multipartFormData:to:method:headers:)
method. I essentially want to know how the key-value pairs are encoded into the request so I know how to decode them server side.