When developing a REST API, is it ok to use Form-Data in POST requests or is that frowned upon? All my methods return a JSON body or only an HTTP code, should this be extended to my POST and PUT requests as well? I think that Form-Data is a lot easier to work with, but that might just be that I'm a bit new to developing REST APIs.
When developing a REST API, is it ok to use Form-Data in POST requests or is that frowned upon?
The ur example of REST is the world wide web, where we posted
application/x-www-form-urlencoded documents to the server and received
So decoupling the request representation from the response representation should be fine.
From a REST perspective, the more interesting question is "how does the client know which key value pairs to include in the request body?" On the web, we had HTML forms, which allow you to describe to a general purpose component how the request payload should be constructed. Without that piece, if you are using out of band communication to tell bespoke clients how to create the request payloads, then you aren't really doing REST.
(Which, by the way, is fine -- if you don't need the REST properties, then you can relax the corresponding constraints. Document exchange protocols described out of band isn't the REST architectural style, but it can get the job done.)
I don't think so. REST API != JSON API.
However, you should consider your clients. I am assuming web browsers are one type of client, since you mention Form Data. This is easy to create in a browser, but I don't think it's as easy to create in an Android or iOS app (I could be wrong here). If you want to target those devices also, you may want to look back in to using JSON.