Martin, I found one problem, possibly 2 with your code.
The first one is with the dimension parameter you're passing.
It should be:
dimension=ou:VAPI4p81HAz;LEVEL-6
instead of:
dimension:ou:VAPI4p81HAz;LEVEL-6
The second problem is URL encoding, specifically the ou dimension
query parameter.
The response I get in this case is "409: Dimension ou is present in
query without any valid dimension options."
It's better to pass the query parameters as a object in the 2nd
parameter of the get, so that the Api class takes care of all the URL
encoding, like this:
You are correct for the error message - now putting back a period means having multiple dimension’s - is there any way to put multiple dimension parameters through the object params? I agree this is much better than using a long query string, but just using an array as value does not work - I tried something like:
Unfortunately using get() directly does not allow for a list as value
for query parameters.
Only the filter parameter supports an array of values in the form you
tried above.
That's one of the problems that the code for supporting analytics
requests addresses.
You can have a peek at this branch, which we're going to merge into
master soon as it is used by the new Maps app to be released.
If you can wait some time, I would suggest to use d2.analytics once is
in master.
But, after some more testing, I figured the error I mentioned "409:
Dimension ou is present in
query without any valid dimension options." is not due to encoding
problems but to the fact that in my orgunit tree I don't have LEVEL-6.
So your initial query should work fine (just the ":" was wrong), you
can add more dimension parameters in the query string.
Still it will be much easier to build analytics requests with d2.analytics.
···
On Thu, Feb 22, 2018 at 9:39 AM, Martin Van Aken <martin@joyouscoding.com> wrote:
You are correct for the error message - now putting back a period means
having multiple dimension's - is there any way to put multiple dimension
parameters through the object params? I agree this is much better than using
a long query string, but just using an array as value does not work - I
tried something like:
I guess it depends on which version of DHIS2 you're running.
The specific analytics/geofeature stuff is all new, so no problem with those.
Sorry I don't have a good answer.
Perhaps some backend dev can comment here.
···
On Fri, Feb 23, 2018 at 12:44 PM, Martin Van Aken <martin@joyouscoding.com> wrote:
Great! Not sure I'll be able to upgrade there this being said. What DHIS2
version are supported by this D2 version?
--
Edoardo Sabadelli
DHIS 2
University of Oslo
edoardo@dhis2.org
I just tested the d2 29x version for the analytics. My problem is I don’t manage to make the simplest example work. I took an analytics query working in the REST API and tried to convert it to d2:
This fails with a “Cannot call a class as a function AnalyticsRequest.js:25” message, on the very first line about the request (looks like request() is not returning what it expect). Any clue?
Martin
···
On Fri, Feb 23, 2018 at 12:31 PM, Edoardo Sabadelli edoardo@dhis2.org wrote:
On Thu, Feb 22, 2018 at 10:14 AM, Edoardo Sabadelli edoardo@dhis2.org wrote:
Still it will be much easier to build analytics requests with d2.analytics.
Support for analytics and geofeatures requests in d2 is out!
I just tested the d2 29x version for the analytics. My problem is I don’t manage to make the simplest example work. I took an analytics query working in the REST API and tried to convert it to d2:
This fails with a “Cannot call a class as a function AnalyticsRequest.js:25” message, on the very first line about the request (looks like request() is not returning what it expect). Any clue?
Martin
On Fri, Feb 23, 2018 at 12:31 PM, Edoardo Sabadelli edoardo@dhis2.org wrote:
On Thu, Feb 22, 2018 at 10:14 AM, Edoardo Sabadelli edoardo@dhis2.org wrote:
Still it will be much easier to build analytics requests with d2.analytics.
Support for analytics and geofeatures requests in d2 is out!
But this falls back to the same problem as before - getting a server error (“uncaught exception: Server connection failed for API request:”) - despite the exact same request working as a REST call.
I just tested the d2 29x version for the analytics. My problem is I don’t manage to make the simplest example work. I took an analytics query working in the REST API and tried to convert it to d2:
This fails with a “Cannot call a class as a function AnalyticsRequest.js:25” message, on the very first line about the request (looks like request() is not returning what it expect). Any clue?
Martin
–
On Fri, Feb 23, 2018 at 12:31 PM, Edoardo Sabadelli edoardo@dhis2.org wrote:
On Thu, Feb 22, 2018 at 10:14 AM, Edoardo Sabadelli edoardo@dhis2.org wrote:
Still it will be much easier to build analytics requests with d2.analytics.
Support for analytics and geofeatures requests in d2 is out!
Thanks, looks like our mails passed each other. You are right, but the “new” was missing from the doc too hence my mistake - my thanks again for your followup!
Martin
···
On Wed, Feb 28, 2018 at 4:03 PM, Edoardo Sabadelli edoardo@dhis2.org wrote:
I just tested the d2 29x version for the analytics. My problem is I don’t manage to make the simplest example work. I took an analytics query working in the REST API and tried to convert it to d2:
This fails with a “Cannot call a class as a function AnalyticsRequest.js:25” message, on the very first line about the request (looks like request() is not returning what it expect). Any clue?
Martin
On Fri, Feb 23, 2018 at 12:31 PM, Edoardo Sabadelli edoardo@dhis2.org wrote:
On Thu, Feb 22, 2018 at 10:14 AM, Edoardo Sabadelli edoardo@dhis2.org wrote:
Still it will be much easier to build analytics requests with d2.analytics.
Support for analytics and geofeatures requests in d2 is out!
Thanks, looks like our mails passed each other. You are right, but the “new” was missing from the doc too hence my mistake - my thanks again for your followup!
Martin
On Wed, Feb 28, 2018 at 4:03 PM, Edoardo Sabadelli edoardo@dhis2.org wrote:
I just tested the d2 29x version for the analytics. My problem is I don’t manage to make the simplest example work. I took an analytics query working in the REST API and tried to convert it to d2:
This fails with a “Cannot call a class as a function AnalyticsRequest.js:25” message, on the very first line about the request (looks like request() is not returning what it expect). Any clue?
Martin
On Fri, Feb 23, 2018 at 12:31 PM, Edoardo Sabadelli edoardo@dhis2.org wrote:
On Thu, Feb 22, 2018 at 10:14 AM, Edoardo Sabadelli edoardo@dhis2.org wrote:
Still it will be much easier to build analytics requests with d2.analytics.
Support for analytics and geofeatures requests in d2 is out!