← Back to team overview

dhis2-devs team mailing list archive

Re: Creating options and optionsets via api

 

It should be there in rev 16809. Not really sure why it went away, but
should be back now.

--
Morten

On Thu, Sep 25, 2014 at 12:26 PM, Mahendra Kariya <
mahendra.kariya@xxxxxxxxxxxxxxxx> wrote:

> Thanks Jason. We will also refer to the dev guide.
>
> Hi Morten,
>
> We tried to create options using the api but were not able to. (We are on
> r 16808 of trunk).
> We posted the following payload to /api/metadata
>
> {
>   "options": [
>     {
>       "code": "ab2d9bcef33",
>       "id": "ab2d9bcef33",
>       "name": "Dressings"
>     }
>   ]
> }
>
>
> The response from DHIS is as follows.
> {
>     "importCount": {
>         "imported": 0,
>         "updated": 0,
>         "ignored": 0,
>         "deleted": 0
>     }
> }
>
>
> DHIS logs are as below.
>
> * INFO  2014-09-25 10:50:07,220 User 'admin' started import at Thu Sep 25
> 10:50:07 IST 2014 (DefaultImportService.java [qtp461220547-20])
> * INFO  2014-09-25 10:50:07,220 Building object-bridge maps (preheatCache:
> true). (DefaultObjectBridge.java [qtp461220547-20])
> * WARN  2014-09-25 10:50:07,223 No IdentifiableObjectStore found for
> class: class org.hisp.dhis.user.UserCredentials
> (DefaultIdentifiableObjectManager.java [qtp461220547-20])
> * WARN  2014-09-25 10:50:07,223 No IdentifiableObjectStore found for
> class: class org.hisp.dhis.user.UserCredentials
> (DefaultIdentifiableObjectManager.java [qtp461220547-20])
> * WARN  2014-09-25 10:50:07,223 No IdentifiableObjectStore found for
> class: class org.hisp.dhis.user.UserCredentials
> (DefaultIdentifiableObjectManager.java [qtp461220547-20])
> * WARN  2014-09-25 10:50:07,224 No IdentifiableObjectStore found for
> class: class org.hisp.dhis.user.UserCredentials
> (DefaultIdentifiableObjectManager.java [qtp461220547-20])
> * WARN  2014-09-25 10:50:07,468 No IdentifiableObjectStore found for
> class: class org.hisp.dhis.user.UserCredentials
> (DefaultIdentifiableObjectManager.java [qtp461220547-20])
> * WARN  2014-09-25 10:50:07,468 No IdentifiableObjectStore found for
> class: class org.hisp.dhis.user.UserCredentials
> (DefaultIdentifiableObjectManager.java [qtp461220547-20])
> * WARN  2014-09-25 10:50:07,469 No IdentifiableObjectStore found for
> class: class org.hisp.dhis.user.UserCredentials
> (DefaultIdentifiableObjectManager.java [qtp461220547-20])
> * WARN  2014-09-25 10:50:07,469 No IdentifiableObjectStore found for
> class: class org.hisp.dhis.user.UserCredentials
> (DefaultIdentifiableObjectManager.java [qtp461220547-20])
> * INFO  2014-09-25 10:50:07,469 Building object-bridge maps took 0.25
> seconds. (DefaultObjectBridge.java [qtp461220547-20])
> * INFO  2014-09-25 10:50:07,470 Importing 1 Options
> (DefaultImportService.java [qtp461220547-20])
> * WARN  2014-09-25 10:50:07,470 Importer for object of type Option not
> found. (DefaultImportService.java [qtp461220547-20])
> * WARN  2014-09-25 10:50:07,471 Can not find getter for 'userCredentials'.
> (DefaultImportService.java [qtp461220547-20])
> * INFO  2014-09-25 10:50:07,472 Import done. Completed in 0.25 seconds.
> (DefaultImportService.java [qtp461220547-20])
>
>
>
>
> On Thu, Sep 25, 2014 at 10:31 AM, Jason Pickering <
> jason.p.pickering@xxxxxxxxx> wrote:
>
>> Also please note, we are moving all of the "dev" stuff to a new Developer
>> Guide (
>> https://www.dhis2.org/doc/snapshot/en/developer/html/dhis2_developer_manual.html)
>> where we hope to be able to offer more up to date and more technical
>> information in the near future.
>>
>> Regards,
>> Jason
>>
>>
>> On Thu, Sep 25, 2014 at 6:05 AM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
>> wrote:
>>
>>> Hi
>>>
>>> As with most of our current metadata, this process is not documented. It
>>> does however follow the normal flow of all our metadata, which means that
>>> objects that are based on UID most be referenced, instead of directly
>>> contained.
>>>
>>> A sample payload would be something like this:
>>>
>>> {
>>>   "options": [
>>>     { "name": "Option 1", "code": "option_1" },
>>>     { "name": "Option 2", "code": "option_2" },
>>>     { "name": "Option 3", "code": "option_3" }
>>>   ],
>>>   "optionSets": [
>>>     { "name": "Options", "options": [ { ... here you must match either
>>> on id or code ... }]
>>>   ]
>>> }
>>>
>>> Remember that if you want to create it all in one go, and don't have the
>>> ID, you can set matching strategy to code.
>>>
>>> If you want to get a larger sample, you can have a look at the output
>>> from this (admin / district):
>>>
>>> https://apps.dhis2.org/dev/api/metadata.json?assumeTrue=false&options=true&optionSets=true
>>>
>>> The way options/optionSets have changed in 2.17 to allow for them to be
>>> translated as our other metadata.
>>>
>>> --
>>> Morten
>>>
>>> On Thu, Sep 25, 2014 at 12:15 AM, Mahendra Kariya <
>>> mahendra.kariya@xxxxxxxxxxxxxxxx> wrote:
>>>
>>>> Hi,
>>>>
>>>> Could you please point us to the documentation for the API to create
>>>> options and option sets?
>>>> We tried searching the user manual
>>>> <https://www.dhis2.org/doc/snapshot/en/user/html/ch31.html>, but
>>>> couldn't find anything.
>>>>
>>>>
>>>>
>>>> Thanks,
>>>> Mahendra
>>>> *Thought*Works
>>>>
>>>
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dhis2-devs
>>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>>
>> --
>> Jason P. Pickering
>> email: jason.p.pickering@xxxxxxxxx
>> tel:+46764147049
>>
>
>

References