1

My REST service needs to return a warning along with an XML representation of the Resource on a GET invocation. Is there any way to represent the warning other than using a Wrapper XML Node to encapsulate the Resource and the Warning?

vivid
  • 109
  • 8
  • You could return a different 2xx HTTP status code. – Andy Oct 24 '15 at 00:00
  • Probably in a custom header, but http://stackoverflow.com/a/9169270/607033 ... So it might be better to use the response body, it depends on the circumstances. – inf3rno Oct 24 '15 at 04:47

1 Answers1

0

It exists a dedicated header for warnings described in the HTTP specification:

The Warning general-header field is used to carry additional information about the status or transformation of a message which might not be reflected in the message. This information is typically used to warn about a possible lack of semantic transparency from caching operations or transformations applied to the entity body of the message.

Something like that:

HTTP/1.1 400 Bad Request
Warning: 299 ServiceName "Invalid input error: X is unrecognized parameter name."

According to your use case, it's something you could consider...

The only other place I see is the response payload...

Hope it helps you, Thierry

Thierry Templier
  • 198,364
  • 44
  • 396
  • 360