blob: b21f4ab668b68aacc91e2af702eb1426a642599a [file] [log] [blame]
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "cloudstack.ent">
%BOOK_ENTITIES;
]>
<!-- Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<section id="response-formats">
<title>Response Formats: XML and JSON</title>
<para>CloudStack supports two formats as the response to an API call. The default response is XML. If you would like the response to be in JSON, add &amp;response=json to the Command String.</para>
<para>The two response formats differ in how they handle blank fields. In JSON, if there is no value for a response field, it will not appear in the response. If all the fields were empty, there might be no response at all.
In XML, even if there is no value to be returned, an empty field will be returned as a placeholder XML element.</para>
<para>Sample XML Response:</para>
<programlisting>
&lt;listipaddressesresponse&gt;
&lt;allocatedipaddress&gt;
&lt;ipaddress&gt;192.168.10.141&lt;/ipaddress&gt;
&lt;allocated&gt;2009-09-18T13:16:10-0700&lt;/allocated&gt;
&lt;zoneid&gt;4&lt;/zoneid&gt;
&lt;zonename&gt;WC&lt;/zonename&gt;
&lt;issourcenat&gt;true&lt;/issourcenat&gt;
&lt;/allocatedipaddress&gt;
&lt;/listipaddressesresponse&gt;
</programlisting>
<para>Sample JSON Response:</para>
<programlisting>
{ "listipaddressesresponse" :
{ "allocatedipaddress" :
[
{
"ipaddress" : "192.168.10.141",
"allocated" : "2009-09-18T13:16:10-0700",
"zoneid" : "4",
"zonename" : "WC",
"issourcenat" : "true"
}
]
}
}
</programlisting>
</section>