Differences between XML and JSON in Coupa

Datatypes in JSON

For JSON, Coupa supports the following: null, boolean, number, and strings.  Precision, version, and similar values use the number datatype, where decimal precision, for example, is a string.  All values not explicitly called out use the string datatype.  

There are four differences to be aware of between how Coupa’s REST APIs work when using JSON vs. using XML.

1. JSON Doesn't Use a Parent Node

In XML we get parent node at the start and end of response. In JSON no parent node available in response.

XML Response

<?xml version="1.0" encoding="UTF-8"?>
	 <id type="integer">41</id>
	 <created-at type="dateTime">2016-10-07T06:56:43-07:00</created-at>
	 <updated-at type="dateTime">2016-10-07T06:56:43-07:00</updated-at>
	 <active type="boolean">true</active>
	 <segment-2 nil="true" />

JSON Response

	 "id": 43,
	 "created-at": "2016-10-07T06:59:46-07:00",
	 "updated-at": "2016-10-07T06:59:46-07:00",
	 "name": "account_1475848721.456090234",
	 "code": "segment11475848721222",
	 "active": true,
	 "segment-1": "segment11475848721222"

2. Different Response for No Results

When there are no results matching the GET query, our XML response throws a 404 error, where the JSON response provides a blank array.

GET: https://dashmaster17-0.coupadev.com/api/accounts?id=NON_EXISTING

XML Response

<?xml version="1.0" encoding="UTF-8"?>
	 <error>No results match your search criteria.</error>


 [ ]

3. Different Nodes for Error Message

XML Response

 <?xml version="1.0" encoding="UTF-8"?>
	 <error>Segment 1 - Cost Center can't be blank.</error>

JSON Response

	 "errors": {
			"account": [
				 "Segment 1 - Cost Center can't be blank"

4. Different response for Country in Address API call

Below are the two sets of responses for a POST API call: http://localhost:3000/api/addresses

XML Response

<?xml version="1.0" encoding="UTF-8"?>
	 <id type="integer">97</id>
	 <created-at type="dateTime">2016-10-07T07:19:07-07:00</created-at>
	 <updated-at type="dateTime">2016-10-07T07:19:07-07:00</updated-at>
	 <location-code nil="true" />
	 <street1>2 W 5th Ave</street1>
			<id type="integer">223</id>
			<name>United States</name>

JSON Response

	 "id": 99,
	 "name": "address_1475850128.91",
	 "street1": "2 W 5th Ave",
	 "street2": "Suite 300",
	 "city": "San Mateo",
	 "state": "CA",
	 "postal_code": "94404",
	 "country_id": 223,
	 "address_owner_type": "BusinessGroup",
	 "parent_address_id": null,
	 "country": "United States"

Related Items

Tagging API

24 April 2017

Use the Tagging API to bring in and export tags to your third-party system.

Integration Runs API

24 April 2017

Use this API to create, query, or update an integration run, as well as update the status.

Dispute Reason API

05 August 2017

Unit of Measure API

30 November 2017

Use this API to specify the unit of measure on orders, invoices, items, and more.