0

I am trying to consume some rest webservices with json request and response format. I am sending all the values in the request even the optional parameters which do not have values.(The default value for all the optional parameter I set as empty string "" to avoid null). One of my colleague pointed out to check empty parameters for optional values and remove them from the request if no value exist.

I know I would be stupid to ask this very basic question but I would like to know the best practice:

Is it good to send empty parameters or we need to check for empty parameters and send only the one which has value.

Prakruti Pathik
  • 392
  • 4
  • 17

1 Answers1

0

Generally the best practise is to follow the API. But if removing optional parameters which do not have values does not affect the target consumers of the API, then you can go for it.

You can check the answer to following post, to get some good reasons to keep the null fields.

Is it Worth To exclude null Fields.

Community
  • 1
  • 1
Shailesh Yadav
  • 1,061
  • 1
  • 15
  • 30