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 7514407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:29:15+00:00 2026-05-30T00:29:15+00:00

If using JSON, we return JSON. If using XML, we return XML. Would it

  • 0

If using JSON, we return JSON. If using XML, we return XML. Would it be acceptable to return form-encoded data for requests where we accept form-encoded data (“application/x-www-form-urlencoded”)?

Also, in the case of errors, what do most implementations do? I see many different variations on the theme.

  • 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-30T00:29:17+00:00Added an answer on May 30, 2026 at 12:29 am

    Returning form-encoded data, while not a terrible approach, is something I’ve never seen in the wild. Best, I think, to stick to more common formats. Most APIs choose a default format to send (usually XML or JSON) when none is specified by the request.

    As for errors, the main principle of REST is using the methods HTTP already supplies, so firstly return the appropriate error status code (in the 400s and 500s) along with an error message in the response body.

    There’s no standard format for the body of an error response—it could be as simple as:

    { "error" : "Invalid articled ID" }
    

    ..or more involved, like Flickr‘s:

    { "stat"    : "fail",
      "code"    : "97",
      "message" : "Missing signature"
    }
    

    ..and its XML equivalent:

    <?xml version="1.0" encoding="utf-8" ?>
    <rsp stat="fail">
      <err code="97" msg="Missing signature" />
    </rsp>
    

    Obviously developers using your API will appreciate more verbose error messages. Mainly I think you should seek consistency in your API—if you have a parameter named Message in one place don’t have one named message in another place.

    As an aside, I’ve dealt with an actual third-party production API that not only made the above faux pas but returned results as pipe (|) separated data enclosed in XML. Literal pipes in values were escaped by another pipe (||). I’ll leave the further complications we discovered up to your imagination. The moral, anyway, is to use structures and techniques that developers are already used to, and more than that be consistent in the choices you make.

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

Sidebar

Related Questions

Question: I'm using eval to parse a JSON return value from one of my
I am trying to return a JSON object from an aspx page using Jayrock.JSON.
My mvc page returns json by using the function Json(mycustomclass) to return a JsonResult
What's the best way to return a Java Map using the JSON format? My
I'm making call to Alfresco Webscripts which return JSON. I do this using GET
Currently I'm using the helper methods outlined here to return some JSON from my
How do you return a serialized JSON object to the client side using ASP.NET
I am using Gson to parse Json. What I don't understand what the return
I would like to post a form using ajax and jquery to a .asmx
Hi, i have been having some problems using JSON data in flash builder lately

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.