dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23369
[Branch ~dhis2-documenters/dhis2/dhis2-docbook-docs] Rev 774: documented how to send to messages to one or more userGroups/organisationUnits with the web-api
------------------------------------------------------------
revno: 774
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2-docbook-docs
timestamp: Tue 2013-07-09 17:12:19 +0700
message:
documented how to send to messages to one or more userGroups/organisationUnits with the web-api
modified:
src/docbkx/en/dhis2_user_man_web_api.xml
--
lp:~dhis2-documenters/dhis2/dhis2-docbook-docs
https://code.launchpad.net/~dhis2-documenters/dhis2/dhis2-docbook-docs
Your team DHIS 2 developers is subscribed to branch lp:~dhis2-documenters/dhis2/dhis2-docbook-docs.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-documenters/dhis2/dhis2-docbook-docs/+edit-subscription
=== modified file 'src/docbkx/en/dhis2_user_man_web_api.xml'
--- src/docbkx/en/dhis2_user_man_web_api.xml 2013-07-05 09:55:38 +0000
+++ src/docbkx/en/dhis2_user_man_web_api.xml 2013-07-09 10:12:19 +0000
@@ -762,7 +762,13 @@
<section>
<title>Writing and reading messages</title>
<para>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 <emphasis role="italic">DHIS Administrator</emphasis> user and send a message to the <emphasis role="italic">Mobile</emphasis> user. We will then pretend to be the mobile user and read our new message.</para>
- <para>The resource we need to interact with when sending and reading messages is the <emphasis role="italic">messageConversations</emphasis> resource. We start by visiting the Web API entry point at <ulink url="http://apps.dhis2.org/demo/api"/> where we find and follow the link to the <emphasis role="italic">messageConversations</emphasis> resource at <ulink url="http://apps.dhis2.org/demo/api/messageConversations"/>. The description tells us that we can use a POST request to create a new message using the following XML format:</para>
+ <para>The resource we need to interact with when sending and reading messages is the <emphasis
+ role="italic">messageConversations</emphasis> resource. We start by visiting the Web API
+ entry point at <ulink url="http://apps.dhis2.org/demo/api"/> where we find and follow the link
+ to the <emphasis role="italic">messageConversations</emphasis> resource at <ulink
+ url="http://apps.dhis2.org/demo/api/messageConversations"/>. The description tells us that
+ we can use a POST request to create a new message using the following XML format for sending
+ to multiple users:</para>
<para><screen><message xmlns="http://dhis2.org/schema/dxf/2.0">
<subject>This is the subject</subject>
<text>This is the text</text>
@@ -772,6 +778,26 @@
<user id="user3ID" />
</users>
</message></screen></para>
+ <para>For sending to all users contained in one or more user groups, we can use:</para>
+ <para><screen><message xmlns="http://dhis2.org/schema/dxf/2.0">
+ <subject>This is the subject</subject>
+ <text>This is the text</text>
+ <userGroups>
+ <userGroup id="userGroup1ID" />
+ <userGroup id="userGroup2ID" />
+ <userGroup id="userGroup3ID" />
+ </users>
+</message></screen></para>
+ <para>For sending to all users connected to one or more organisation units, we can use:</para>
+ <para><screen><message xmlns="http://dhis2.org/schema/dxf/2.0">
+ <subject>This is the subject</subject>
+ <text>This is the text</text>
+ <organisationUnits>
+ <organisationUnit id="ou1ID" />
+ <organisationUnit id="ou2ID" />
+ <organisationUnit id="ou3ID" />
+ </users>
+</message></screen></para>
<para>Since we want to send a message to our friend the mobile user we need to look up her identifier. We do so by going to the Web API entry point and follow the link to the <emphasis role="italic">users</emphasis> resource at <ulink url="http://apps.dhis2.org/demo/api/users"/>. We continue by following link to the mobile user at <ulink url="http://apps.dhis2.org/demo/api/users/PhzytPW3g2J"/> where we learn that her identifier is <emphasis role="italic">PhzytPW3g2J</emphasis>. We are now ready to put our XML message together to form a message where we want to ask the mobile user whether she has reported data for January 2012:</para>
<screen><message xmlns="http://dhis2.org/schema/dxf/2.0">
<subject>Mortality data reporting</subject>