cloudstack/docs/tmp/en-US/html/making-api-request.html

36 lines
4.5 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>4.1. Making API Requests</title><link rel="stylesheet" type="text/css" href="Common_Content/css/default.css" /><link rel="stylesheet" media="print" href="Common_Content/css/print.css" type="text/css" /><meta name="generator" content="publican 2.8" /><meta name="package" content="Apache_CloudStack-API_Developers_Guide-4.0.0-incubating-en-US-1-" /><link rel="home" href="index.html" title="CloudStack API Developer's Guide" /><link rel="up" href="api-calls.html" title="Chapter 4. Calling the CloudStack API" /><link rel="prev" href="api-calls.html" title="Chapter 4. Calling the CloudStack API" /><link rel="next" href="enabling-api-call-expiration.html" title="4.2. Enabling API Call Expiration" /></head><body><p id="title"><a class="left" href="http://cloudstack.org"><img src="Common_Content/images/image_left.png" alt="Product Site" /></a><a class="right" href="http://docs.cloudstack.org"><img src="Common_Content/images/image_right.png" alt="Documentation Site" /></a></p><ul class="docnav"><li class="previous"><a accesskey="p" href="api-calls.html"><strong>Prev</strong></a></li><li class="next"><a accesskey="n" href="enabling-api-call-expiration.html"><strong>Next</strong></a></li></ul><div xml:lang="en-US" class="section" id="making-api-request" lang="en-US"><div class="titlepage"><div><div><h2 class="title" id="making-api-request">4.1. Making API Requests</h2></div></div></div><div class="para">
All CloudStack API requests are submitted in the form of a HTTP GET/POST with an associated command and any parameters. A request is composed of the following whether in HTTP or HTTPS:
</div><div class="itemizedlist"><ul><li class="listitem"><div class="para">
CloudStack API URL: This is the web services API entry point(for example, http://www.cloud.com:8080/client/api)
</div></li><li class="listitem"><div class="para">
Command: The web services command you wish to execute, such as start a virtual machine or create a disk volume
</div></li><li class="listitem"><div class="para">
Parameters: Any additional required or optional parameters for the command
</div></li></ul></div><div class="para">
A sample API GET request looks like the following:
</div><pre class="programlisting">http://localhost:8080/client/api?command=deployVirtualMachine&amp;serviceOfferingId=1&amp;diskOfferingId=1&amp;templateId=2&amp;zoneId=4&amp;apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXq-jB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ&amp;signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D
</pre><div class="para">
Or in a more readable format:
</div><pre class="programlisting">
1. http://localhost:8080/client/api
2. ?command=deployVirtualMachine
3. &amp;serviceOfferingId=1
4. &amp;diskOfferingId=1
5. &amp;templateId=2
6. &amp;zoneId=4
7. &amp;apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXqjB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ
8. &amp;signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D
</pre><div class="para">
The first line is the CloudStack API URL. This is the Cloud instance you wish to interact with.
</div><div class="para">
The second line refers to the command you wish to execute. In our example, we are attempting to deploy a fresh new virtual machine. It is preceded by a (?) to separate itself from the CloudStack API URL.
</div><div class="para">
Lines 3-6 are the parameters for this given command. To see the command and its request parameters, please refer to the appropriate section in the CloudStack API documentation. Each parameter field-value pair (field=value) is preceded by an ampersand character (&amp;).
</div><div class="para">
Line 7 is the user API Key that uniquely identifies the account. See Signing API Requests on page 7.
</div><div class="para">
Line 8 is the signature hash created to authenticate the user account executing the API command. See Signing API Requests on page 7.
</div></div><ul class="docnav"><li class="previous"><a accesskey="p" href="api-calls.html"><strong>Prev</strong>Chapter 4. Calling the CloudStack API</a></li><li class="up"><a accesskey="u" href="#"><strong>Up</strong></a></li><li class="home"><a accesskey="h" href="index.html"><strong>Home</strong></a></li><li class="next"><a accesskey="n" href="enabling-api-call-expiration.html"><strong>Next</strong>4.2. Enabling API Call Expiration</a></li></ul></body></html>