On 17 May 2019, at 12:15, Sven Van Caekenberghe <sven@stfx.eu> wrote:
As a related question - how would I know to use #addPart: vs: #formAt: ?
By knowing/understanding a bit more about HTTP ? ;-)
As I wrote in my reply to Ben: Although curl is powerful, well known and well supported, I would not say it is a great standard for interface design, it is way too complex. Zn tries to approach HTTP from an object design standpoint. You pass along a ZnMultiPartFormDataEntity object that contains ZnMimeParts as entity to your POST request. HTTP transfers resources or entities between a client and a server using a limited set of verbs (ZnMessage subclasses ZnRequest and ZnResponse). Headers (ZnHeaders) contain meta data about HTTP messages. Simplified, with a GET you request a resource, with a DELETE you remove a resource, with POST you create a new resource and with PUT/PATCH you update an existing resource. Resources/entities can be anything, they are described by mime types (ZnMimeType) and identified by URLs/URIs (ZnUrl). Zn models them as subclasses of ZnEntity. The most fundamental ones are ZnStringEntity for text based data and ZnByteArrayEntity for binary data. ZnStreamEntity is a special variant that support streaming transfers.
From the world of HTML (not HTTP !), more specifically, Forms, there are 2 popular resources/entities: ZnApplicationFormUrlEncodedEntity and ZnMultiPartFormDataEntity. These have structure that is also exposed as an API - and for which there is some extra support in ZnClient.
Most real REST APIs use JSON or XML for their payloads (see the #forJsonREST method for example). HTH, Sven