0

I am developing an application on angular that makes several http request to the server which are mostly POST and GET request.

I wanted to know if we can use a mix of both

'Content-Type': 'application/x-www-form-urlencoded 

and

'Content-Type': 'application/json

as per the request i.e One request uses application/json and the other application/x-www-form-urlencoded.

Or is it a good practice to only use one content-type.

Stacy J
  • 2,721
  • 15
  • 58
  • 92
  • Mainly content type comes from server side. Since server knows which type of response it is sending. It is not possible to mix both. Only possible for different response itself. – Partha Sarathi Ghosh Jul 19 '16 at 06:27
  • @ParthaSarathiGhosh What I mean is one request is application/json and the other is application/x-www-form-urlencoded...is that a good practice.. – Stacy J Jul 19 '16 at 06:28
  • 1
    Highly possible from server side. Off course this is a good practice. – Partha Sarathi Ghosh Jul 19 '16 at 06:33
  • 1
    Yes, you can change the content type of your POST requests (and GET too but they have no request body so it doesn't matter) via headers. See http://stackoverflow.com/a/30970229/283366 – Phil Jul 19 '16 at 06:37

0 Answers0