Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6845853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:33:06+00:00 2026-05-27T00:33:06+00:00

When constructing an API response, which method is better for (manually) returning the status

  • 0

When constructing an API response, which method is better for (manually) returning the status code to indicate the validity of the request:

1 – Embed a response code within the JSON response

{
  'status_code' => 200,
  'status_message' => 'OK',
  'data' => { ... }
}

2 – Or is it better to modify the HTTP Headers Status field?

Request URL:http://somesite.com
Request Method:GET
Status Code: 200 (EDITING THIS ONE)

I would think that the HTTP Statuses should only be regarding connection errors and file retrieval errors that occur at the server level rather than altering this to address application level errors.

Any good articles and resources to read would be very appreciated as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:33:06+00:00Added an answer on May 27, 2026 at 12:33 am

    I have found the best way to present errors in a REST Request is to change the HTTP Status Code to the proper error, and embed the error in the response.

    If you are using JSON, it might look like this, with the status code set to 500 for this example:

    {"error" : "An error has occurred while trying to read from the database."}
    

    This is the same method that Microsoft CRM uses to report errors, and it has proved to be a good method; RESTFul applications will not fail to parse the response if they are expecting JSON (or XML, if you are using that).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use this code block of php in C#: $fb->api(array( 'method' =>
I'm constructing a method to take in an ArrayList(presumably full of objects) and then
I'm constructing an ecommerce application in Symfony, and I have a page which lists
I'm trying to use an API which sends a fax. I have a PHP
This seems to be an Android-wide problem, which you can see in API demos
I am using Win32::API to call an arbitary function exported in a DLL which
I'm working on the development of a C++ API which uses custom-designed plugins to
I am calling a server side api which returns me the DB rows in
I have recently started looking into Google Charts API for possible use within the
There's a method which is called inside an animation block by a third party

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.