You usually put Content-Disposition:form-data; name="field-name" as the part header for the text field. I tried to do as instructed which makes my body looks like this:
						body += "--\(boundary)\r\n"
						body += "Content-Disposition:form-data; name=\"image\""
						body += "\r\n\r\n\(base64Image ?? "")\r\n"
						body += "Content-Disposition:form-data; name=\"title\""
						body += "\r\n\r\n\(name)\r\n"
						body += "--\(boundary)--\r\n"
The request still works but the title of the picture is not defined
I think I did not mention it but the request I'm trying to use is the post image from the Imgur API
https://apidocs.imgur.com/#de179b6a-3eda-4406-a8d7-1fb06c17cb9c Edit: Also tried adding a boundary between to have something like this:
body += "--\(boundary)\r\n"
						body += "Content-Disposition:form-data; name=\"image\""
						body += "\r\n\r\n\(base64Image ?? "")\r\n"
						body += "--\(boundary)--\r\n"
						body += "Content-Disposition:form-data; name=\"title\""
						body += "\r\n\r\n\(name)\r\n"
						body += "--\(boundary)--\r\n"
but this is still not working
Edit2:
Had to change the way of putting the boundary to something like this:
body += "--\(boundary)\r\n"
which makes the body look like this:
body += "--\(boundary)\r\n"
						body += "Content-Disposition:form-data; name=\"image\""
						body += "\r\n\r\n\(base64Image ?? "")\r\n"
						body += "--\(boundary)\r\n"
						body += "Content-Disposition:form-data; name=\"title\""
						body += "\r\n\r\n\(name)\r\n"
						body += "--\(boundary)--\r\n"
Which is now working
Thanks again for your help and the time you took to answer my questions !
Topic:
Programming Languages
SubTopic:
Swift
Tags: