=== modified file 'src/docbkx/en/dhis2_user_man_web_api.xml' --- src/docbkx/en/dhis2_user_man_web_api.xml 2012-04-27 12:12:51 +0000 +++ src/docbkx/en/dhis2_user_man_web_api.xml 2012-04-29 09:33:31 +0000 @@ -119,6 +119,49 @@ Regarding the id schemes, by default the identifiers used in the XML messages refer to the DHIS stable object identifiers. In certain interoperability situations we might experience that the external system decides the identifiers of the objects. In that case we can use the code property of the organisation unit and data element objects to set fixed identifiers dictated by the other system. When importing data values we hence need to reference the code property instead of the uid property, and can do so using the dataElementIScheme and orgUnitIdScheme paramaters.
+ Example: Reading data values + This section explains how to retrieve data values from the Web API by interacting with the dataValueSets resource. Data values can currently be retrieved in XML format. Since we want to read data we will use the GET HTTP verb. We will also specify that we are interested in the XML resource representation by including an Accept HTTP header with our request. The following query parameters are required: + + Data value set query parameters + + + + + Parameter + + + Description + + + + dataSet + Data set identifier + + + period + Period identifier in ISO format + + + orgUnit + Organisation unit identifier + + + +
+ It is assumed that we have posted data values to DHIS according to the previous section called "Sending data values". We can now put together our request and send it using cURL: + curl "http://apps.dhis2.org/demo/api/dataValueSets?dataSet=pBOMPrpg1QX&period=201201&orgUnit=DiszpKrYNg8" -H "Accept:application/xml" -u admin:district -v + The response will look something like this: + HTTP/1.1 200 OK +Content-Type: application/xml + +<?xml version='1.0' encoding='UTF-8'?><dataValueSet xmlns="http://dhis2.org/schema/dxf/2.0" dataSet="pBOMPrpg1QX" completeDate="2012-01-02" period="201201" orgUnit="DiszpKrYNg8"> +<dataValue dataElement="eY5ehpbEsB7" period="201201" orgUnit="DiszpKrYNg8" categoryOptionCombo="bRowv6yZOF2" value="10003"/> +<dataValue dataElement="Ix2HsbDMLea" period="201201" orgUnit="DiszpKrYNg8" categoryOptionCombo="bRowv6yZOF2" value="10002"/> +<dataValue dataElement="f7n9E0hX8qk" period="201201" orgUnit="DiszpKrYNg8" categoryOptionCombo="bRowv6yZOF2" value="10001"/> +</dataValueSet> + The header tells us that the request was processed successfully and that we are receiving a response in XML format. The XML message looks familiar - it is the data values we sent in the previous section. +
+
Example: Writing and reading messages DHIS 2 features a mechanism for sending messages for purposes such as user feedback, notifications and general information to users. Messages are delivered to the DHIS 2 message inbox but can also be sent to the user's email addresses and mobile phones as SMS. In this example we will see how we can utilize the Web API to send and read messages. We will pretend to be the DHIS Administrator user and send a message to the Mobile user. We will then pretend to be the mobile user and read our new message. The resource we need to interact with when sending and reading messages is the messageConversations resource. We start by visiting the Web API entry point at where we find and follow the link to the messageConversations resource at . The description tells us that we can use a POST request to create a new message using the following XML format: