← Back to team overview

dhis2-devs team mailing list archive

Re: [d2 lib] - API call failing with "Server connection failed for API request"

 

On Thu, Feb 22, 2018 at 9:39 AM, Martin Van Aken
<martin@xxxxxxxxxxxxxxxx> 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:
>
> return getInstance().then(d2 =>
>           d2.Api.getApi().get('analytics/events/query/jqKm7VLgdzL', {
>             stage: 'tbLC6IHktf0',
>             dimension: ['ou:VAPI4p81HAz;LEVEL-6','xxx'],
>             displayProperty: 'NAME'
>         }));
>
> but this is not working. Any clues?

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.
https://github.com/dhis2/d2/pull/144

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.

-- 
Edoardo Sabadelli
DHIS 2
University of Oslo
edoardo@xxxxxxxxx
http://www.dhis2.org


Follow ups

References