Web service design - how should my web service response?
Example a Phone number can have type "Home telephone", "Business telephone", "Customer Service telephone" etc
Should my web service API return in the response with "PhoneTypeCode" or PhoneTypeName (used for display)?
Example of Business telephone type
1) PhoneTypeCode: "business"
2) PhoneType: "Business telephone"
3) Return both?
Depending on your needs either approach is fine.
When deciding consider:
- if client have special hadnling for different types - in this case code would be easier to handle.
- if there are localization concerns and if your service already provides localized responses (i.e. you return numbers/dates as localized strings, or you require culture to be passed in request and other strings are localized accordingly). If your server does not provide any locaization support - returing strings could be confsing.
- if set of types is complete - if not retyring type as string (non-localized) may be better as it forces client to start handling "unknown" types earlier.