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

  • SEARCH
  • Home
  • 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 1007915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:41:25+00:00 2026-05-16T08:41:25+00:00

I am just about to make a webservice available for fellow programmers in my

  • 0

I am just about to make a webservice available for fellow programmers in my sector using PHP on my own server.

As this is the first time I have done this, I first investigated APIs that I frequently use, Flickr etc.

My service returns granular data extracted from a very large csv file by examining GET arguments, it is read-only.

The data is returned in a variety of formats, xml, json, jsonp etc.

example of the call: /?offices=ABC|XYZ&format=xml

Firstly, I’d like to know if I am I correct in terming my service an “API”?

Also I would also like to know how best to handle failure.

I return straight text messages in the case of a user not submitting the expected input – “you failed to submit any offices”.

In the case of any other unforeseen malfunction, at the moment it returns a failure message in payload of the chosen format, eg json with the single array “fail” in it and I have documented this.

Having read up a little on REST recently, when a failure is not caused by misuse of the “API” – should I return something other than HTTP code 200?

If you were accessing this service, what would you prefer to see?

Should I make this another GET option?

e.g /?offices=ABC|XYZ&format=xml&on_failure=http

Or am I getting muddled between the terms API and REST?

SO suggested this post, which deals with 400/401

What's an appropriate HTTP status code to return by a REST API service for a validation failure?

but I am looking for clarification about the terms I am using. If the payload contains the error message – as in the case of Flickr then why should I wander away from that?

  • 1 1 Answer
  • 2 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-16T08:41:26+00:00Added an answer on May 16, 2026 at 8:41 am

    The larger providers like Flickr and Twitter have muddied the definition of REST quite a bit. Many developers now mistakenly believe that any service or API over HTTP is “RESTful.” What you describe here is more of a data Web service using a form of RPC. Truly RESTful APIs use fluent HTTP and Web standards, and are resource centric.

    To answer the main question about HTTP status codes, I would say that for RPC services it’s not necessary, as the HTTP status codes won’t always directly translate to method call errors. A better approach would be to map your own error codes and return them along with the status message.

    For example, an RPC service for user lookups may return the following on success:

    SUCCESS=1
    USERNAME=example
    FIRSTNAME=Example
    LASTNAME=User
    DISPLAYNAME=Example User
    

    The same service may return the following on failure:

    SUCCESS=0
    ERRORCODE=1002
    ERRORMSG=User subsystem error; requested user was not found.
    

    In an RPC service, the exact details of the response are very flexible. All it does is relay the results of the method call to the invoker. As long as you document what the developer should see, and return clear and consistent messages, it’ll work out just fine. The only HTTP status codes an RPC service should return are 200 and 500 (and only then when things break so badly you can’t even return a proper error).

    Back to the matter of REST, the same user service can be made RESTful if we think of a user as a resource and use an appropriate URL scheme. The very, very basic makeup of a RESTful API are as follows:

    GET /api/users – should return a list
    of available user accounts in the
    system.

    GET /api/users/example – should return
    details of the example account;
    returns a 404 HTTP status if the user
    does not exist.

    POST /api/users – create a new user
    account; should return a link to the
    newly created account (ways of doing
    this vary, but the LOCATION header
    makes sense here). Various HTTP status
    codes may be returned depending on the
    result.

    PUT /api/users/example – edit the
    details of an existing user account.
    Various HTTP status codes may be
    returned depending on the result.

    DELETE /api/users/example – delete an
    existing user account. Various HTTP
    status codes may be returned depending
    on the result.

    The standard HTTP status codes most common to RESTful interfaces are below.

    • 200 OK – The request was successfully completed. If this request created a new resource that is addressable with a URI, and a response body is returned containing a representation of the new resource, a 200 status will be returned with a Location header containing the canonical URI for the newly created resource.
    • 201 Created – A request that created a new resource was completed, and no response body containing a representation of the new resource is being returned. A Location header containing the canonical URI for the newly created resource should also be returned.
    • 202 Accepted – The request has been accepted for processing, but the processing has not been completed. Per the HTTP/1.1 specification, the returned entity (if any) SHOULD include an indication of the request’s current status, and either a pointer to a status monitor or some estimate of when the user can expect the request to be fulfilled.
    • 204 No Content – The server fulfilled the request, but does not need to return a response message body.
    • 400 Bad Request – The request could not be processed because it contains missing or invalid information (such as validation error on an input field, a missing required value, and so on).
    • 401 Unauthorized – The authentication credentials included with this request are missing or invalid.
    • 403 Forbidden – The server recognized your credentials, but you do not possess authorization to perform this request.
    • 404 Not Found – The request specified a URI of a resource that does not exist.
    • 405 Method Not Allowed – The HTTP verb specified in the request (DELETE, GET, HEAD, POST, PUT) is not supported for this request URI.
    • 406 Not Acceptable – The resource identified by this request is not capable of generating a representation corresponding to one of the media types in the Accept header of the request.
    • 409 Conflict – A creation or update request could not be completed, because it would cause a conflict in the current state of the resources supported by the server (for example, an attempt to create a new resource with a unique identifier already assigned to some existing resource).
    • 500 Internal Server Error – The server encountered an unexpected condition which prevented it from fulfilling the request.
    • 501 Not Implemented – The server does not (currently) support the functionality required to fulfill the request.
    • 503 Service Unavailable – The server is currently unable to handle the request due to temporary overloading or maintenance of the server.

    Hopefully this information is useful, and not overload. 🙂

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

Sidebar

Related Questions

I just found out about ie7-js ; IE7 is a JavaScript library to make
Just asked a question about linking Boost libraries in the make file. Thanks to
I know I could just make all the Mix_Musics public, and not worry about
I am just about done writing my first mergesort program and am running into
I just started working with jqGrid this week. I'm attempting to make a generic
I have this web app created using MVC3 and need to make a Windows
I just learned about the Template Method pattern in this answer to a question
I've just migrated and deployed my first Azure Web Role this week and now
Hi just about to get the dev team to start looking at the next
I am just about to get started with Kinect development and am hoping someone

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.