Child pages
  • Chapter 2 - Discovery - Testing access to the web service with the browser

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Code Block
languagehtml/xml
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
  <api shop_name="MYSHOP">
    <addresses>...</addresses>
    <carriers>...</carriers>
    <cart_rules>...</cart_rules>
    <carts>...</carts>
    <categories>...</categories>
    <combinations>...</combinations>
    <configurations>...</configurations>
    <contacts>...</contacts>
    <content_management_system>...</content_management_system>
    <countries>...</countries>
    <currencies>...</currencies>
    <customer_messages>...</customer_messages>
    <customer_threads>...</customer_threads>
    <customers>...</customers>
    <deliveries>...</deliveries>
    <employees>...</employees>
    <groups>...</groups>
    <guests>...</guests>
    <image_types>...</image_types>
    <images>...</images>
    <languages>...</languages>
    <manufacturers>...</manufacturers>
    <order_carriers>...</order_carriers>
    <order_details>...</order_details>
    <order_discounts>...</order_discounts>
    <order_histories>...</order_histories>
    <order_invoices>...</order_invoices>
    <order_payments>...</order_payments>
    <order_states>...</order_states>
    <orders>...</orders>
    <price_ranges>...</price_ranges>
    <product_feature_values>...</product_feature_values>
    <product_features>...</product_features>
    <product_option_values>...</product_option_values>
    <product_options>...</product_options>
    <product_suppliers>...</product_suppliers>
    <products>...</products>
    <search >...</search>
    <shop_groups>...</shop_groups>
    <shops>...</shops>
    <specific_price_rules>...</specific_price_rules>
    <specific_prices>...</specific_prices>
    <states>...</states>
    <stock_availables>...</stock_availables>
    <stock_movement_reasons>...</stock_movement_reasons>
    <stock_movements>...</stock_movements>
    <stocks>...</stocks>
    <stores>...</stores>
    <suppliers>...</suppliers>
    <supply_order_details>...</supply_order_details>
    <supply_order_histories>...</supply_order_histories>
    <supply_order_receipt_histories>...</supply_order_receipt_histories>
    <supply_order_states>...</supply_order_states>
    <supply_orders>...</supply_orders>
    <tags tags><tags>...</tags>
    <tax_rule_groups>...</tax_rule_groups>
    <tax_r	ules>rules>...</tax_rules>
    <taxes>...</taxes>
    <translated_configurations>...</translated_configurations>
    <warehouse_product_locations>...</warehouse_product_locations>
    <warehouses>...</warehouses>
    <weight_ranges>...</weight_ranges>
    <zones>...</zones>
  </api>
  <api shop_name="MYOTHERSHOP">...</api>
  <api shop_name="YETANOTHERSHOP">...</api>
</prestashop>

...

Code Block
languagehtml/xml
titleResult for http://example.com/api/customers
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
  <customers>
    <customer id="1" xlink:href="http://example.com/api/customers/1"/>
    <customer id="12" xlink:href="http://example.com/api/customers/2"/>
    <customer id="13" xlink:href="http://example.com/api/customers/3"/>
    <customer id="14" xlink:href="http://example.com/api/customers/4"/>
    <customer id="15" xlink:href="http://example.com/api/customers/5"/>
    <customer id="16" xlink:href="http://example.com/api/customers/76"/>
    <customer id="17" xlink:href="http://example.com/api/customers/87"/>
    ...
  </customers>
</prestashop>

...

Code Block
languagehtml/xml
titleResult for http://example.com/api/customers/1
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
  <customer>
    <id><![CDATA[1]]></id>
    <id_default_group xlink:href="http://example.com/api/groups/3"><![CDATA[3]]></id_default_group>
    <id_lang xlink:href="http://example.com/api/languages/1"><![CDATA[1]]></id_lang>
    <newsletter_date_add><![CDATA[2013-04-23 11:40:52]]></newsletter_date_add>
    <ip_registration_newsletter></ip_registration_newsletter>
    <last_passwd_gen><![CDATA[2013-04-23 05:40:52]]></last_passwd_gen>
    <secure_key><![CDATA[5b402973df21cd42a303a2fdfce91df7]]></secure_key>
    <deleted><![CDATA[0]]></deleted>
    <passwd><![CDATA[a747961318242111b33ed551dcff10a9]]></passwd>
    <lastname><![CDATA[DOE]]></lastname>
    <firstname><![CDATA[John]]></firstname>
    <email><![CDATA[[email protected]]]></email>
    <id_gender><![CDATA[1]]></id_gender>
    <birthday><![CDATA[1970-01-15]]></birthday>
    <newsletter><![CDATA[1]]></newsletter>
    <optin><![CDATA[1]]></optin>
    <website></website>
    <company></company>
    <siret></siret>
    <ape></ape>
    <outstanding_allow_amount><![CDATA[0.000000]]></outstanding_allow_amount>
    <show_public_prices><![CDATA[0]]></show_public_prices>
    <id_risk><![CDATA[0]]></id_risk>
    <max_payment_days><![CDATA[0]]></max_payment_days>
    <active><![CDATA[1]]></active>
    <note></note>
    <is_guest><![CDATA[0]]></is_guest>
    <id_shop><![CDATA[1]]></id_shop>
    <id_shop_group><![CDATA[1]]></id_shop_group>
    <date_add><![CDATA[2013-04-23 11:40:52]]></date_add>
    <date_upd><![CDATA[2013-04-23 11:40:52]]></date_upd>
    <associations>
      <groups node_type="group">
        <group xlink:href="http://example.com/api/groups/3">
          <id><![CDATA[3]]></id>
        </group>
      </groups>
    </associations>
  </customer>
</prestashop>

Adding and editing a resource

The http://example.com/api/customers/1 example is not only available using the HTTP GET method, but also using POST, PUT, DELETE, HEAD.

Example

The XML file found at http://example.com/api/customers/1, whose link is found in the list of resources (see above), gives you the properties of customer account that has "1" as its ID.

Thus, by jumping from link to link, you can browse the web service to access all resources in XMLTo add a customer (or any other resource, for that matter), you simply need to GET the XML blank data for the resource (/api/customer?schema=blank), fill it with your changes, and POST the whole XML file to the /api/customers/ URL again. PrestaShop will take care of adding everything in the database, and will return an XML file indicating that the operation has been successful, along with the ID of the newly created customer.

To edit an existing resource: GET the full XML file for the resource you want to change (/api/customers/7), edit its content as needed, then PUT the whole XML file back to the same URL again.