Phred Menyhert
Phred Menyhert

Reputation: 2450

Convention for making a read-only REST interface?

I'm new to REST API development and I haven't been able to find any guidance on what to do if you don't want to support all the operations.

For instance, say I wanted to make a read-only API, what do I do if I recieve one of the "write" verbs (PUT, POST, DELETE, etc.)? Is there a convention for this (like return a 404, or a 500, or something)?

Upvotes: 2

Views: 130

Answers (2)

Darrel Miller
Darrel Miller

Reputation: 142014

405 is for method that is not supported by a resource. 501 is when your server does not recognize the method. I believe the error is a 4xx not a 5xx because it is the client that requested something that it is not allowed to do. The client can fix this. The server is not at fault, it simply chose not to implement that method.

Upvotes: 1

Don Roby
Don Roby

Reputation: 41127

The convention defined by RFC 2616 is to return a 501 (Not Implemented) response for a command you're not supporting.

Upvotes: 2

Related Questions