Hi

This question is not specifically about PHP but since my application is in PHP I m posting it here.


I have spent the past few days doing some research on the API responses of various online services. I am confused and I want your suggestions.

Do you think the following response makes sense and is industry standard way of generating an API response?


Success XML
Code:
<?xml version='1.0' encoding='UTF-8'?>
<output>
 <result>1</result>
 <message>User Added Successfully</message>
</output>
Success JSON
Code:
{"result":true,"message":"User Added Successfully"}


Error XML
Code:
<?xml version='1.0' encoding='UTF-8'?>
<output>
 <result>0</result>
 <message>User Already Exits</message>
</output>
Error JSON
Code:
{"result": false, "message":"User Already Exits"}
In the above responses, I am sending a "result" key that holds a boolean value (true / false). True in case of success and false in case an error occurs.

The second key is "message" that holds the respective messages.

The reason I am asking this question is because one of my friend claims that its not a standard way of sending API responses and that we do not need to send the "result" key at all. We should return a key "errMsg" with the error message in case of error and in case of success we can send a true value. And users who are using the API can check if the "errMsg" key exists then handle the response as an error otherwise assume it as a success.

So can someone throw some light on this please?

Thanks in advance