View source | Discuss this page | Page history | Printable version   

How to Create And Update Business Entities Using Web Services



The objective of this article is to show you how to use some of Openbravo's available web services to create business entities and/or to update them.

Therefore, we will exemplary show it for these two sets of web services:

Recommended articles

Before reading this guide, we recommend that you take some time to get further information about these two web service concepts being used to achieve the goal of this article:

Execution Steps

To add or update entities, we use HTTP commands. To execute any HTTP commands, we could create a Java class and use the available classes related to the HTTP protocol.
(Note: We could do the same for any other protocol or scripting language like PHP).

Alternatively, we could use a plugin like Poster (for Firefox; downoad here) which allows us to execute any HTTP command on an URL of your choice.
In the examples we will show, we will make use of this plugin and we will be assuming that our Openbravo environment is running on a local machine via



We are about to create a new invoice header, so that the URL for this case will be


Into "User Auth" we have to insert the credentials which we use to get access to the web service (which are by the way the same that we use to get into the application). You have to take into account that the visibility of the data within the web service will be the same as if you logged into the application with the default role of this user. The "Content-Type" of the Request will be "text/xml" and the least content will be as follows, where the "id"s will be replaced by those that we want to be present in the invoice. Note that we have set the attribute "salesTransaction" to "true", indicating that this is a sales invoice:

    "entityName":          "Invoice",
    "active":              true,
    "organization":        { "id": "E443A31992CB4635AFCAEABE7183CE85" },
    "salesTransaction":    true,
    "documentType":        { "id": "7FCD49652E104E6BB06C3A0D787412E3" },
    "transactionDocument": { "id": "7FCD49652E104E6BB06C3A0D787412E3" },
    "documentNo":          "1000050",
    "accountingDate":      "2012-05-29",
    "invoiceDate":         "2012-05-29",
    "currency":            { "id": "102" },
    "priceList":           { "id": "AEE66281A08F42B6BC509B8A80A33C29" },
    "businessPartner":     { "id": "9E6850C866BD4921AD0EB7F7796CE2C7" },
    "partnerAddress":      { "id": "BFE1FB707BA84A6D8AF61A785F3CE1C1" },
    "paymentTerms":        { "id": "66BA1164A7394344BB9CD1A6ECEED05D" },
    "paymentMethod":       { "id": "A97CFD2AFC234B59BB0A72189BD8FC2A" }
View larger
View larger
We use the HTTP POST command with this data. We will get a "200 OK" response back, indicating that everything went well with the invoice data we have just created.

To make an update, we will use the PUT command. For instance, to update a Business Partner's name, we will execute that command on this URL:


with the following content:

    "entityName": "BusinessPartner",
    "id":         "A6750F0D15334FB890C254369AC750A8",
    "name":       "New Name"


Now we will create a new invoice header using XML REST. In the case of REST, the process is analog to the method explained above, except of the URL on which we have to execute the HTTP POST command:


, and obviously the invoice data, since we have to convert it into the xml format:

<?xml version="1.0" encoding="UTF-8"?>
<ob:Openbravo xmlns:ob="">
    <organization id="E443A31992CB4635AFCAEABE7183CE85"/>
    <documentType id ="7FCD49652E104E6BB06C3A0D787412E3"/>
    <transactionDocument id ="7FCD49652E104E6BB06C3A0D787412E3"/>
    <currency id="102"/>
    <priceList id="AEE66281A08F42B6BC509B8A80A33C29"/>
    <businessPartner id="9E6850C866BD4921AD0EB7F7796CE2C7"/>
    <partnerAddress id="BFE1FB707BA84A6D8AF61A785F3CE1C1"/>
    <paymentTerms id="66BA1164A7394344BB9CD1A6ECEED05D"/>
    <paymentMethod id="A97CFD2AFC234B59BB0A72189BD8FC2A"/>
View larger
View larger
And for our example of updating the Business Partner's name, we will need the following content:
<?xml version="1.0" encoding="UTF-8"?>
<ob:Openbravo xmlns:ob="">
<BusinessPartner id="A6750F0D15334FB890C254369AC750A8">
<name>New Name</name>

Retrieved from ""

This page has been accessed 15,671 times. This page was last modified on 27 August 2013, at 10:48. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.