Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning client about deprecated REST API

We are deprecating the REST service and we want to inform the client about this. what is the best practice followed?

I can think of following options

  1. Pass the deprecation warning message as part of service response JSON/XML
  2. Pass the warning message in HTTP “Warning” Response header.

Could you please share your ideas?

like image 664
user2436721 Avatar asked Apr 24 '15 09:04

user2436721


People also ask

What do you do with a deprecated API?

While deprecated classes, methods, and fields are still implemented, they may be removed in future implementations, so you should not use them in new code, and if possible rewrite old code not to use them.

What is a deprecated warning?

Deprecation warnings are a common thing in our industry. They are warnings that notify us that a specific feature (e.g. a method) will be removed soon (usually in the next minor or major version) and should be replaced with something else.

What does it mean if an API is deprecated?

Obsoleted: This API method is no longer used, but might still be backwards compatible. In the API Reference, these are indicated as follows: public int getDeviceKnoxId () This method is deprecated. Not supported: This API method will no longer work, and should be removed from apps.

How do you mark API as deprecated?

Starting with J2SE 5.0, you deprecate a class, method, or field by using the @Deprecated annotation. Additionally, you can use the @deprecated Javadoc tag tell developers what to use instead. Using the annotation causes the Java compiler to generate warnings when the deprecated class, method, or field is used.


1 Answers

I would not change anything in the status code or in the service response to be backward compatible. I would add a "Warning" header in the response.

Warning: 299 - "Deprecated API"

You could also check this (old) response: https://softwareengineering.stackexchange.com/questions/55081/deprecate-a-web-api-best-practices

like image 116
JP. Aulet Avatar answered Oct 14 '22 06:10

JP. Aulet