Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Endpoints >
Currently, you can't post data into the Xero API using JSON. In theory it shouldn't be massively difficult for this to be written, but there hasn't been much call for it to be added.

What development platform are you using (Java, .net, ruby, php, perl, javascript, etc.)? Using xml for the request and response messages covers pretty much all popular development platforms, but I understand that json can be easier than xml on some platforms.
 

Dan Barratt (Xero Staff)  

I'm on .NET.

How about POSTing / PUTing using XML, but getting the response in JSON?
 

mtambalo_at_blastasia Tambalo  

You can get the reponse in JSON by setting the "Accept" value in the http header to "application/json"

http://blog.xero.com/developer/api-overview/http-get/
 

W. Abdullah (Community Manager)  

That's all well and good, but if you have a validation error, but are asking for a JSON response, the error is not correctly returned.

That is, you get a 500 instead.

<ApiException xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ErrorNumber>500</ErrorNumber>
<Type>UnknownErrorException</Type>
<Message>An error occurred in Xero. Please contact api@xero.com. Also check the API Status page http://developer.xero.com/api-status/ for current service status.</Message>
</ApiException>

Note that this very same request without the accept header returns the correct validation message (in my case, timesheet already exists).

I think there is a bug when rendering json error responses.
 

Matthew Schinckel  

Hi Mathew, I've looked into the issue and have logged a ticket. Will post an update to this discussion once we've got a fix in place.

Cheers,
- Richard
 

Richard Fortune (Xero Staff)  

Super. I'll look forward to removing my code that re-runs the request asking for XML on a 500 response :)
 

Matthew Schinckel  

Can you post JSON now or is it still limited to XML? Thanks!
 

Shaun Clark  

@Shaun: According to http://developer.xero.com/documentation/getting-started/http-requests-and-responses/ you must submit requests the same (i.e.: body of xml=...).
 

Matthew Schinckel  

Can I please add my vote (make it 100000 votes) to allow JSON as a format for GET, POST and PUT? It would really bring Xero into line with contemporary API's and I am a little shocked you cannot POST or PUT in JSON; it is sooooo common!

http://developer.xero.com/documentation/getting-started/http-requests-and-responses/

"Only XML formatted requests are accepted. The XML must be sent in an html form parameter called “xml”."

It is so clunky and bloated. Please add JSON across the board...

Thanks
 

Owen Batt  

+1

Im currently using Play Framework 2 (Scala) and JSON is the preferred way communication.
 

Roy Lin  

Xero seems so new and hip that I'm a little surprised that the XML api isn't deprecated yet.

I'm totally shocked that they still have yet to even build a full JSON api!

(cringing at the thought of doing XML in nodejs)

Can we please oh please get a full JSON api? Its almost 2015 already.

 

Bryan Morris  

+1 Would be great to know the status of full support for JSON. It's the de-facto standard as a data interchange format for Web APIs. Other accounting software's are also getting support for Web APIs with JSON support by default.
 

Ismail Kaleem  

Hey Xero! it's 2015! please get your act together and support JSON... I would be kind of embarrassed if I were you. :(
 

Andrew Stone  

I'll second (third? fifth?) this - XML is a pain!
 

Isaac Udy  

Just starting to work with the Xero API... Shocked and amazed that they don't accept JSON for POST yet! Come on guys!! It's 2015! Do you need me to fax you a memo on JSON?

Even Quickbooks Online lets you do this:
https://developer.intuit.com/docs/api/accounting
You just gonna let them disrespect you like that??

Don't get me wrong. I can't stand QB online and love what you guys are building here. Just show me that my trust is not mis-placed :)
 

Jonathan Dickson  

JSON format is more convenient than XML. JSON is the developer's choice when dealing with RESTful API. Hope to see it coming soon in next version of Xero.
+1
 

Zuhaib Dar  

Please include JSON request for get and put will help most Rest service developers
 

shailu chougale  

Wow, I can't believe JSON is not supported. It should be as simple as one code configuration value to do it.

Every other API I've dealt with including QBO support JSON.
 

Jacob Gur  

Apologies if this has already been answered, if I specify the "Accept" content type to be JSON on a PUT/POST that generates a 400 (validation error) will the error be returned to me as JSON or as XML?
 

Nick Jacobs  

The lack of JSON PUT/POST especially frustrating since you guys don't seem to care about keeping an up to date schema, and don't even use it internally, so the only thing XML is actually good for (validation and auto stub generating) can't be leveraged reliably by 3rd party library maintainers:
https://github.com/XeroAPI/XeroAPI-Schemas/issues/32
 

James Broberg  

I would love for the API to have a json endpoint too.

My main problem is, at the minute, if I post XML to add a new contact, even though I set the "accept" header to JSON, I get xml back!
My system is based around 2 way data binding from JSON and I can't remake it specifically for XML just because your API will not send back what it is supposed to.
Can you please help me??
 

Luke Smith  

Looking forward for JSON request.

Myself working for a software development company. One of our client want an integration for Xero and Salesforce. And I feel it will be easy to develop using JSON request over XML request. As we are going to provide these kind of integration to other clients too. It would be great if we have JSON request option too.
 

Parani T K  

yep - seriously this needs to happen. I hadn't seen that bit about updating with xml only until I'd pretty much built all the JSON output (I mean you return it as JSON, so why not?), and then I discover that you hadn't bothered to implement that.

Not sure why I can't just put a stream containing the blob back rather than mucking round with the whole url-encoded thing.. unless that somehow helps with the authentication/signing.
 

Michael Geddes  

It's crazy that this hasn't been addressed yet!
 

Phil C.  

So, is this ever going to happen? It shouldn't take 6 years to address this....
Any update on this issue would be great and benefit all your developers.
 

Drew Gilmore  

is json supported or not yet?
 

Dilip Chaudhary  

Yes, this is supported, as of last week. No documentation yet other than this: https://devblog.xero.com/json-for-the-accounting-api-974a3b8adfb4
 

Drew Gilmore  

Yes, we now support JSON. All you need to do is set the HTTP headers “Accept: application/json” and/or "Content-Type: application/json" when making a request.
See https://developer.xero.com/documentation/api/requests-and-responses for more information.
 

Amy Martin (Xero Staff)