XML Response

When the system is done processing your XML data it always returns an XML response back which you may either choose to look at, store, or even parse within your application for further automation.

Response to a valid XML request

The XML Response ClickaPost’s API generates in return may look similar to this:

<?xml version="1.0" encoding="UTF-8"?>
<response>
	<processedIn>0.291 seconds</processedIn>
<totalPosts>2</totalPosts>
<acceptedPosts>1</acceptedPosts>
<rejectedPosts>1</rejectedPosts>
<posts>
		<post>
			<accepted>true</accepted>
			<id>123</id>
			<customId></customId>
			<notes>
		<note>Photo url 'http://some.domain.ext/image.jpg' does not link to a valid image file, therefore, it will be skipped.</note>
		<note>This post does not contain your own Custom ID. It is recommended you use Custom ID in order to prevent any duplicate posts.</note>
</notes>
			<errors></errors>
		</post>
		<post>
			<accepted>false</accepted>
			<id></id>
			<customId>1234</customId>
			<notes></notes>
			<errors>
<error>Post category is not valid [it must be a unique ClickaPost Category ID of a category with no subcategories defined (i.e. you cannot post directly in For Sale, but rather in a specific subcategory)]</error>
<error></error>
</errors>
		</post>
	</posts>
</response>

As you may see from the above example response, it’s quite easy to see what happened to your request. It reports the time it took for your XML data to validate, total number of posts that have been found, total number of accepted posts, total number of rejected posts (those which generated an error), and furthermore, it specifies each and every post within <posts> branch with detailed information:

  • success status <accepted> as in true/false
  • ClickaPost’s internal XML Queue ID for that post :: <id> (if no ID is provided post hasn’t been accepted)
  • your own <customId> so you may use this information in your application to match your posts with Sync status on ClickaPost
  • notes: information you should be aware of but which was not severe enough to cause your post to FAIL – but should be taken care of in the future
  • errors: information on why your post failed

Dissecting the above example, we see that one post was accepted and one failed. The first one which was accepted is stored internally at ClickaPost under XML queue ID 123, since no <customId> data was provided it was returned empty, and under notes we can see that the photo provided was not found and since we were in non-STRICT mode it was simply removed. Accepted posts NEVER contain any errors, only notes.

On the other hand, the second post was not accepted, as indicated by <accepted> = false, no ClickaPost queue ID has been set since it hasn’t been stored, and since <customId> was provided for this post – it’s conveniently returned in the response so you may know which of you posts failed. There are no notes on this post; however, there is an error (which clearly explains what caused the post to be rejected): Post category was not set correctly.

Response to an invalid XML request

In some cases, there may be fatal errors that prevent the XML Parser from even starting the process (like invalid Token ID, or malformed XML file). In this case, the response from the server contains only one <message> describing the issue. Here’s an example:

<?xml version="1.0" encoding="UTF-8"?>
<response>
	<message>INVALID XML :: Found unclosed tags</message>
</response>

As with everything in this API – interpreting the response is easy for both humans and machines.

Next Step

 
xml_response.txt · Last modified: 2008/12/15 21:14 by peconi
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki