Re: [Dhis2-devs] [Dhis2-users] WebAPI Bugs when filtering by level and ancestor

2017-07-27 Thread Gaurav Kumar
Hi Morten,

Could this be linked to the issue I reported earlier?

[Bug]DHIS2-1911(WEB API: Recursive 
filtering not working with more than one AND filter).

Regards,
GAURAV

From: Dhis2-devs 
[mailto:dhis2-devs-bounces+gkumar=internationalmedicalcorps@lists.launchpad.net]
 On Behalf Of Morten Olav Hansen
Sent: Thursday, July 27, 2017 7:16 AM
To: Mamadou Diao Diallo 
Cc: dhis2-users ; DHIS 2 developers 

Subject: Re: [Dhis2-devs] [Dhis2-users] WebAPI Bugs when filtering by level and 
ancestor

Hi Mamadou

Could you please report a bug to JIRA? jira.dhis2.org

--
Morten Olav Hansen
Senior Engineer, DHIS 2
University of Oslo
http://www.dhis2.org

On Wed, Jul 26, 2017 at 11:52 PM, Mamadou Diao Diallo 
mailto:diao_dia...@gn.jsi.com>> wrote:
Hi Devs,
I'm currently using dhis2 API to develop an App, but I have some troubles when 
I filter by level and ancestor in the same time.

To clarify:

Everything is ok with this one : 
URL/api/25/organisationUnits.json?filter=level:eq:'+level+'&fields=[id,displayName]

But by adding ancestor parameter the level is just ignored:
URL/api/25/organisationUnits.json?filter=level:eq:'+level+'&filter=ancestors.id:eq:'+ancestorId+'&fields=[id,displayName]

I will really appreciate your help and any link for an advanced dhis2 API topic.

Best,

Diao

--
DIALLO Mamadou Diao Conseiller IT, Specialiste de DHIS 2 ( District Health 
Information Software )
[https://www.measureevaluation.org/++theme++wink-measure/images/meval_logo.png] 
[http://jsi.com/Managed/Images/Common/JSI_WebHeader.png]
Projet de Renforcement du Système d'Information Sanitaire en Guinée
Phone : 623909413 | 662256106
Skype : diawwdiallo
www.jsi.com

___
Mailing list: https://launchpad.net/~dhis2-users
Post to : 
dhis2-us...@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-users
More help   : https://help.launchpad.net/ListHelp

___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] [Dhis2-users] WebAPI Bugs when filtering by level and ancestor

2017-07-27 Thread Jason Pickering
Seems to work as its documented (at least in some cases)

https://play.dhis2.org/dev/api/dataElements?filter=name:like:IPT

Gives all data elements which contain IPT

https://play.dhis2.org/dev/api/dataElements?filter=name:like:IPT&filter=name:like:1st

Gives all data elements which contain IPT and 1st (but no others).

This however, does not work

https://play.dhis2.org/dev/api/27/organisationUnits.json?filter=level:eq:4&filter=ancestors.id:eq:O6uvpzGd5pu&fields=id,name,ancestors,level

as you get some level 3 and some level 4 units.

This however does work

https://play.dhis2.org/dev/api/27/organisationUnits.json?filter=level:eq:4&filter=path:like:O6uvpzGd5pu&fields=id,name,ancestors,level


So, maybe the problem is filtering in the nested collections?

/Jason

On Thu, Jul 27, 2017 at 10:09 AM, Gaurav Kumar <
gku...@internationalmedicalcorps.org> wrote:

> Hi Morten,
>
>
>
> Could this be linked to the issue I reported earlier?
>
>
>
> [image: Bug]DHIS2-1911 (WEB
> API: Recursive filtering not working with more than one AND filter).
>
>
>
> Regards,
>
> GAURAV
>
>
>
> *From:* Dhis2-devs [mailto:dhis2-devs-bounces+gkumar=
> internationalmedicalcorps@lists.launchpad.net] *On Behalf Of *Morten
> Olav Hansen
> *Sent:* Thursday, July 27, 2017 7:16 AM
> *To:* Mamadou Diao Diallo 
> *Cc:* dhis2-users ; DHIS 2 developers <
> dhis2-devs@lists.launchpad.net>
> *Subject:* Re: [Dhis2-devs] [Dhis2-users] WebAPI Bugs when filtering by
> level and ancestor
>
>
>
> Hi Mamadou
>
>
>
> Could you please report a bug to JIRA? jira.dhis2.org
>
>
> --
>
> Morten Olav Hansen
>
> Senior Engineer, DHIS 2
>
> University of Oslo
>
> http://www.dhis2.org
>
>
>
> On Wed, Jul 26, 2017 at 11:52 PM, Mamadou Diao Diallo <
> diao_dia...@gn.jsi.com> wrote:
>
> Hi Devs,
>
> I'm currently using dhis2 API to develop an App, but I have some troubles
> when I filter by *level* and *ancestor* in the same time.
>
>
>
> To clarify:
>
>
>
> *Everything is ok with this one :* URL/api/25/organisationUnits.
> json?filter=level:eq:'+level+'&fields=[id,displayName]
>
>
>
> *But by adding ancestor parameter the level is just ignored:*
>
> URL/api/25/organisationUnits.json?filter=level:eq:'+level+'
> &filter=ancestors.id:eq:'+ancestorId+'&fields=[id,displayName]
>
>
>
> I will really appreciate your help and any link for an advanced dhis2 API
> topic.
>
>
>
> Best,
>
>
>
> Diao
>
>
>
> --
>
> *DIALLO Mamadou Diao Conseiller IT, Specialiste de DHIS 2 ( District
> Health Information Software )*
>
> *[image:
> https://www.measureevaluation.org/++theme++wink-measure/images/meval_logo.png]*
>  *[image: http://jsi.com/Managed/Images/Common/JSI_WebHeader.png]*
>
> *Projet de Renforcement du Système d'Information Sanitaire en Guinée*
>
> *Phone : 623909413 | 662256106*
>
> *Skype : diawwdiallo*
>
> www.jsi.com
>
>
> ___
> Mailing list: https://launchpad.net/~dhis2-users
> Post to : dhis2-us...@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help   : https://help.launchpad.net/ListHelp
>
>
>
> ___
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to : dhis2-devs@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
>


-- 
Jason P. Pickering
email: jason.p.picker...@gmail.com
tel:+46764147049
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


[Dhis2-devs] Epidemiological Week

2017-07-27 Thread Nayeem Al Mifthah
Dear Developers,

While selecting epidemiological week starting Sunday, I have found that, it
exclude first week of 2017.

I think it should start with 1st January 2017.

[image: Inline image 1]


*Nayeem Al Mifthah*
*Consultant for HSS, Health MIS, M&E*
Email: n.mift...@gmail.com
Cell:+8801914030574
Skype: nayeem.a.m
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


[Dhis2-devs] Fwd: [Dhis2-users] API calls using Node.js examples

2017-07-27 Thread Knut Staring
This is a good question for the dev list.

-- Forwarded message --
From: Jesus Solano-Roman 
Date: Thu, Jul 27, 2017 at 3:15 PM
Subject: [Dhis2-users] API calls using Node.js examples
To: "dhis2-users lists.launchpad.net" 


Hello all.

I would like to know if someone could point out to examples or perhaps give
an example of a typical Web API call done using Node.js

The examples in the documentation are either using cURL or using the direct
browser "endpoint", but usually do not take into account oAuth
authentication (e.g. using a token instead of user credentials) and how to
wrap all that into a Node.js request.

In the use case of developing a web application, both the "Bearer token"
and the following API calls should be done using Node (or say, PHP) and not
cURL. So for instance, this example from the documentation should actually
exist as a Node request:

curl -H "Authorization: Bearer 07fc551c-806c-41a4-9a8c-10658bd15435"
$SERVER/api/26/dataElements.json

Any help would be greatly appreciated.

Thanks,


Antonio Solano.
Broad Institute of MIT and Harvard, Boston, MA, USA.

___
Mailing list: https://launchpad.net/~dhis2-users
Post to : dhis2-us...@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-users
More help   : https://help.launchpad.net/ListHelp




-- 
Knut Staring
Dept. of Informatics, University of Oslo
Norway: +4791880522
Skype: knutstar
http://dhis2.org
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] [Dhis2-users] WebAPI Bugs when filtering by level and ancestor

2017-07-27 Thread Mamadou Diao Diallo
Many thanks for all of you,
I will just use the @Jason idea with path filter before to have a best way
to handle it.

Best

Diao

On Thu, Jul 27, 2017 at 8:26 AM, Jason Pickering <
jason.p.picker...@gmail.com> wrote:

> Seems to work as its documented (at least in some cases)
>
> https://play.dhis2.org/dev/api/dataElements?filter=name:like:IPT
>
> Gives all data elements which contain IPT
>
> https://play.dhis2.org/dev/api/dataElements?filter=name:
> like:IPT&filter=name:like:1st
>
> Gives all data elements which contain IPT and 1st (but no others).
>
> This however, does not work
>
> https://play.dhis2.org/dev/api/27/organisationUnits.json?
> filter=level:eq:4&filter=ancestors.id:eq:O6uvpzGd5pu&
> fields=id,name,ancestors,level
>
> as you get some level 3 and some level 4 units.
>
> This however does work
>
> https://play.dhis2.org/dev/api/27/organisationUnits.json?
> filter=level:eq:4&filter=path:like:O6uvpzGd5pu&fields=id,
> name,ancestors,level
>
>
> So, maybe the problem is filtering in the nested collections?
>
> /Jason
>
> On Thu, Jul 27, 2017 at 10:09 AM, Gaurav Kumar  internationalmedicalcorps.org> wrote:
>
>> Hi Morten,
>>
>>
>>
>> Could this be linked to the issue I reported earlier?
>>
>>
>>
>> [image: Bug]DHIS2-1911 (WEB
>> API: Recursive filtering not working with more than one AND filter).
>>
>>
>>
>> Regards,
>>
>> GAURAV
>>
>>
>>
>> *From:* Dhis2-devs [mailto:dhis2-devs-bounces+gkumar=
>> internationalmedicalcorps@lists.launchpad.net] *On Behalf Of *Morten
>> Olav Hansen
>> *Sent:* Thursday, July 27, 2017 7:16 AM
>> *To:* Mamadou Diao Diallo 
>> *Cc:* dhis2-users ; DHIS 2 developers <
>> dhis2-devs@lists.launchpad.net>
>> *Subject:* Re: [Dhis2-devs] [Dhis2-users] WebAPI Bugs when filtering by
>> level and ancestor
>>
>>
>>
>> Hi Mamadou
>>
>>
>>
>> Could you please report a bug to JIRA? jira.dhis2.org
>>
>>
>> --
>>
>> Morten Olav Hansen
>>
>> Senior Engineer, DHIS 2
>>
>> University of Oslo
>>
>> http://www.dhis2.org
>>
>>
>>
>> On Wed, Jul 26, 2017 at 11:52 PM, Mamadou Diao Diallo <
>> diao_dia...@gn.jsi.com> wrote:
>>
>> Hi Devs,
>>
>> I'm currently using dhis2 API to develop an App, but I have some troubles
>> when I filter by *level* and *ancestor* in the same time.
>>
>>
>>
>> To clarify:
>>
>>
>>
>> *Everything is ok with this one :* URL/api/25/organisationUnits.j
>> son?filter=level:eq:'+level+'&fields=[id,displayName]
>>
>>
>>
>> *But by adding ancestor parameter the level is just ignored:*
>>
>> URL/api/25/organisationUnits.json?filter=level:eq:'+level+'&
>> filter=ancestors.id:eq:'+ancestorId+'&fields=[id,displayName]
>>
>>
>>
>> I will really appreciate your help and any link for an advanced dhis2 API
>> topic.
>>
>>
>>
>> Best,
>>
>>
>>
>> Diao
>>
>>
>>
>> --
>>
>> *DIALLO Mamadou Diao Conseiller IT, Specialiste de DHIS 2 ( District
>> Health Information Software )*
>>
>> *[image:
>> https://www.measureevaluation.org/++theme++wink-measure/images/meval_logo.png]*
>>  *[image: http://jsi.com/Managed/Images/Common/JSI_WebHeader.png]*
>>
>> *Projet de Renforcement du Système d'Information Sanitaire en Guinée*
>>
>> *Phone : 623909413 | 662256106*
>>
>> *Skype : diawwdiallo*
>>
>> www.jsi.com
>>
>>
>> ___
>> Mailing list: https://launchpad.net/~dhis2-users
>> Post to : dhis2-us...@lists.launchpad.net
>> Unsubscribe : https://launchpad.net/~dhis2-users
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>>
>> ___
>> Mailing list: https://launchpad.net/~dhis2-devs
>> Post to : dhis2-devs@lists.launchpad.net
>> Unsubscribe : https://launchpad.net/~dhis2-devs
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>
>
> --
> Jason P. Pickering
> email: jason.p.picker...@gmail.com
> tel:+46764147049
>



-- 
*DIALLO Mamadou Diao Conseiller IT, Specialiste de DHIS 2 **( District
Health Information Software )*


*Projet de Renforcement du Système d'Information Sanitaire en Guinée*
*Phone : 623909413 | 662256106*
*Skype : diawwdiallo*
www.jsi.com
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] [Dhis2-users] Event analytics endpoint broken

2017-07-27 Thread Lars Helge Øverland
Hi Jesus,

the API endpoint should work. There are a few parameters which are
mandatory:

https://play.dhis2.org/demo/api/26/analytics/events/aggregate/eBAyeGv0exc.json?dimension=ou:ImspTQPwCqd&dimension=pe:LAST_4_QUARTERS&dimension=fWIAEtYVEGk&dimension=oZg33kd9taw&stage=Zj7UnCAulEk&displayProperty=SHORTNAME&outputType=EVENT&value=vV9UWAZohSf&aggregationType=AVERAGE

Have a look at the docs here:

https://docs.dhis2.org/master/en/developer/html/webapi_event_analytics.html

regards,

Lars


On Thu, Jul 27, 2017 at 6:07 PM, Jesus Solano-Roman <
asol...@broadinstitute.org> wrote:

> Hello all.
>
> We've been trying to get the Event Analytics endpoint to work (e.g.:)
>
> *https://play.dhis2.org/dev/api/analytics/events
> *
>
> but we get a 404 error from the server. The same happens on our local
> installation of DHIS2.
>
> Is there a reason why this is happening? Must something setting be enabled
> or is this endpoint broken?
>
> Alternatively, we basically just want to get a list of the Data Elements
> used in a particular program (event). We think this endpoint will do that
> but if there's another endpoint we can use feel free to suggest.
>
> Otherwise our options are limited to looping and getting unique
> identifiers using the
>
> */api/events?program=[...]*
>
> endpoint.
>
>
> As always, thanks for your kind help.
>
>
> Antonio Solano.
> Broad Institute of MIT and Harvard. Boston, MA. USA
>
> ___
> Mailing list: https://launchpad.net/~dhis2-users
> Post to : dhis2-us...@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help   : https://help.launchpad.net/ListHelp
>
>


-- 
Lars Helge Øverland
Lead developer, DHIS 2
University of Oslo
Skype: larshelgeoverland
l...@dhis2.org
http://www.dhis2.org 
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] [Dhis2-users] Event analytics endpoint broken

2017-07-27 Thread Lars Helge Øverland
No worries.

Lars

On Thu, Jul 27, 2017 at 6:22 PM, Jesus Solano-Roman <
asol...@broadinstitute.org> wrote:

> Hi Lars.
>
> Thanks for the quick reply. This should fix it, my apologies for not
> reading more carefully.
>
>
>
> *Antonio Solano-Roman*
>
> Data Visualization & User Experience Design
> Sabeti Lab - Broad Institute
>
> On Jul 27 2017, at 12:19 pm, Lars Helge Øverland  wrote:
>
>> Hi Jesus,
>>
>> the API endpoint should work. There are a few parameters which are
>> mandatory:
>>
>> https://play.dhis2.org/demo/api/26/analytics/events/
>> aggregate/eBAyeGv0exc.json?dimension=ou:ImspTQPwCqd&
>> dimension=pe:LAST_4_QUARTERS&dimension=fWIAEtYVEGk&
>> dimension=oZg33kd9taw&stage=Zj7UnCAulEk&displayProperty=
>> SHORTNAME&outputType=EVENT&value=vV9UWAZohSf&aggregationType=AVERAGE
>> 
>>
>> Have a look at the docs here:
>>
>> https://docs.dhis2.org/master/en/developer/html/webapi_
>> event_analytics.html
>> 
>>
>> regards,
>>
>> Lars
>>
>>
>> On Thu, Jul 27, 2017 at 6:07 PM, Jesus Solano-Roman <
>> asol...@broadinstitute.org> wrote:
>>
>> Hello all.
>>
>> We've been trying to get the Event Analytics endpoint to work (e.g.:)
>>
>> *https://play.dhis2.org/dev/api/analytics/events
>> *
>>
>> but we get a 404 error from the server. The same happens on our local
>> installation of DHIS2.
>>
>> Is there a reason why this is happening? Must something setting be
>> enabled or is this endpoint broken?
>>
>> Alternatively, we basically just want to get a list of the Data Elements
>> used in a particular program (event). We think this endpoint will do that
>> but if there's another endpoint we can use feel free to suggest.
>>
>> Otherwise our options are limited to looping and getting unique
>> identifiers using the
>>
>> */api/events?program=[...]*
>>
>> endpoint.
>>
>>
>> As always, thanks for your kind help.
>>
>>
>> Antonio Solano.
>> Broad Institute of MIT and Harvard. Boston, MA. USA
>>
>> ___
>> Mailing list: https://launchpad.net/~dhis2-users
>> 
>> Post to : dhis2-us...@lists.launchpad.net
>> Unsubscribe : https://launchpad.net/~dhis2-users
>> 
>> More help   : https://help.launchpad.net/ListHelp
>> 
>>
>>
>>
>>
>> --
>> Lars Helge Øverland
>> Lead developer, DHIS 2
>> University of Oslo
>> Skype: larshelgeoverland
>> l...@dhis2.org
>> http://www.dhis2.org 
>>
>>


-- 
Lars Helge Øverland
Lead developer, DHIS 2
University of Oslo
Skype: larshelgeoverland
l...@dhis2.org
http://www.dhis2.org 
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] Fwd: [Dhis2-users] API calls using Node.js examples

2017-07-27 Thread Morten Olav Hansen
Hi

I don't think we have any immediate plans to include this in the docs, the
idea about using cURL is that it's completely language neutral and any
language these days should give you the tools to interact with the API.

That said, a simple example for fetch the data elements from a DHIS2 server
would be (you need node-fetch installed):

const fetch = require( "node-fetch" );

const createAuthenticationHeader = (username, password) => {
  return "Basic " + new Buffer( username + ":" + password ).toString(
"base64" );
};

fetch( '
https://play.dhis2.org/dev/api/dataElements?paging=false&filter=domainType:eq:TRACKER',
{
  headers: {
"Accept": "application/json",
"Authorization": createAuthenticationHeader( 'admin', 'district' )
  }
} )
  .catch( err => console.error( err ) )
  .then( res => res.json() )
  .then( res => {
console.log( res.dataElements.length );
  } )
  .catch( err => console.error( err ) );

If you would want to use an OAuth2 bearer token instead you would change
the Authorization header.

-- 
Morten Olav Hansen
Senior Engineer, DHIS 2
University of Oslo
http://www.dhis2.org

On Thu, Jul 27, 2017 at 10:36 PM, Knut Staring  wrote:

> This is a good question for the dev list.
>
> -- Forwarded message --
> From: Jesus Solano-Roman 
> Date: Thu, Jul 27, 2017 at 3:15 PM
> Subject: [Dhis2-users] API calls using Node.js examples
> To: "dhis2-users lists.launchpad.net" 
>
>
> Hello all.
>
> I would like to know if someone could point out to examples or perhaps
> give an example of a typical Web API call done using Node.js
>
> The examples in the documentation are either using cURL or using the
> direct browser "endpoint", but usually do not take into account oAuth
> authentication (e.g. using a token instead of user credentials) and how to
> wrap all that into a Node.js request.
>
> In the use case of developing a web application, both the "Bearer token"
> and the following API calls should be done using Node (or say, PHP) and not
> cURL. So for instance, this example from the documentation should actually
> exist as a Node request:
>
> curl -H "Authorization: Bearer 07fc551c-806c-41a4-9a8c-10658bd15435"
> $SERVER/api/26/dataElements.json
>
> Any help would be greatly appreciated.
>
> Thanks,
>
>
> Antonio Solano.
> Broad Institute of MIT and Harvard, Boston, MA, USA.
>
> ___
> Mailing list: https://launchpad.net/~dhis2-users
> Post to : dhis2-us...@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help   : https://help.launchpad.net/ListHelp
>
>
>
>
> --
> Knut Staring
> Dept. of Informatics, University of Oslo
> Norway: +4791880522 <918%2080%20522>
> Skype: knutstar
> http://dhis2.org
>
> ___
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to : dhis2-devs@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
>
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


[Dhis2-devs] Fwd: Re: Fwd: [Dhis2-users] API calls using Node.js examples

2017-07-27 Thread Knut Staring
-- Forwarded message --
From: "Samson Bekele" 
Date: Jul 28, 2017 6:34 AM
Subject: Re: [Dhis2-devs] Fwd: [Dhis2-users] API calls using Node.js
examples
To: "Knut Staring" 
Cc:

I tried to call the api from node js application. Here the lesson I learned.

1. CORS, because your node.js and the api are running in different server,
the browser doesn't allow to call the api especially you are developing
your node.js application in local host. In order to avoid this issue, you
need to configure a proxy, to tell your api location and port. But I think
if you are working on real web domain, I think this is not an issue, or you
modify the host file and instead of local host, you call testdev.com, may
be you will not have this issue.

I can start by cloning the dhis app which are developed using react, redux
and node and webpack, they wrap the api call through d2, and you can check
the code and have a better understanding of the react application. But once
you build the react application, you need to add your running node app url
as white list in the dhis2, I think in setting, there is place called
whitelist, other wise, it will not communication to the dhis2 application,
I cloned the maintenance-app, I build, run it and it works fine.

In my case, I am using freezer instead of redux, and I use request module
which are wrap around another js file. or you can use fetch or axios but
you need to figure how once you called the api and getting the data, to put
this data on your state management you selected, in the case of redux, in
your store,

the final advice, you can also generate your own api directly from the
postgres database, this depends on what data you are looking for, for
example in my case I want to get all the user in the user table, I can
create the route
{
path: '/api/users',
method: 'GET',
handler: Handlers.getuserHandler,
config: {
auth: false
}
}
here is my handlers
Handlers.getuserHandler= function(request, reply){
//to run a query we just pass it to the pool
//after we're done nothing has to be taken care of
//we don't have to return any client to the pool or close a connection
pool.query('SELECT * from users', function(err, result) {
  if(err) {
return console.error('error running query', err);
  }
   reply(result.rows);
});
};

I am using hapi as web application framework for this example, and pg
module to connect to postgres, this works if your really know how the dhis2
postgres database are structured and you know how to get the data, or you
need to go in the code and figure out how they structure the sql for end
point.

I using pg module to help me to connect to the postgres database and query
the database.

I am not actually working on real dhis2 application, I just like the
application and working on the app in my free time. I deployed the instance
in my digital ocean cloud server, and looking how to use it to manage my
data I want to visualize. I think this might help you, if I confuse you
more, you can discard my suggestion.

Thanks,
Samson



--
*From:* Knut Staring 
*To:* DHIS 2 developers 
*Sent:* Thursday, July 27, 2017 9:37 AM
*Subject:* [Dhis2-devs] Fwd: [Dhis2-users] API calls using Node.js examples

This is a good question for the dev list.

-- Forwarded message --
From: *Jesus Solano-Roman* 
Date: Thu, Jul 27, 2017 at 3:15 PM
Subject: [Dhis2-users] API calls using Node.js examples
To: "dhis2-users lists.launchpad.net" 


Hello all.

I would like to know if someone could point out to examples or perhaps give
an example of a typical Web API call done using Node.js

The examples in the documentation are either using cURL or using the direct
browser "endpoint", but usually do not take into account oAuth
authentication (e.g. using a token instead of user credentials) and how to
wrap all that into a Node.js request.

In the use case of developing a web application, both the "Bearer token"
and the following API calls should be done using Node (or say, PHP) and not
cURL. So for instance, this example from the documentation should actually
exist as a Node request:

curl -H "Authorization: Bearer 07fc551c-806c-41a4-9a8c- 10658bd15435"
$SERVER/api/26/dataElements. json

Any help would be greatly appreciated.

Thanks,


Antonio Solano.
Broad Institute of MIT and Harvard, Boston, MA, USA.

__ _
Mailing list: https://launchpad.net/~dhis2- users

Post to : dhis2-users@lists.launchpad. net

Unsubscribe : https://launchpad.net/~dhis2- users

More help   : https://help.launchpad.net/ ListHelp





-- 
Knut Staring
Dept. of Informatics, University of Oslo
Norway: +4791880522 <+47%20918%2080%20522>
Skype: knutstar
http://dhis2.org
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to: dhis2-devs@lists.lau