REST Web Services

Best Practices to follow while writing REST WS :

  1. http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api
  2. http://blog.mwaysolutions.com/2014/06/05/10-best-practices-for-better-restful-api/

Form encoding while making POST requests :

When you make a POST request, you have to encode the data that forms the body of the request in some way.

HTML forms provide three methods of encoding.

  • application/x-www-form-urlencoded (the default)
  • multipart/form-data
  • text/plain

Use multipart/form-data if the request contains a File upload and it should be used in combination with the INPUT element, type=”file”.
Use application/x-www-form-urlencoded otherwise, which is the default if you omit enctype header in the request.
NEVER use text/plain as it only used if you want to debug the payload you are sending as part of HTTP request.

URL Encode Query params : When sending requests to REST API from POSTMAN, make sure you URL-Encode the query parameters part of the request.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s