Hi Alan Seems like you have an invalid optionset, i..e an optionset without code?
-- Morten On Fri, Jun 19, 2015 at 7:47 AM, Alan Hill <[email protected]> wrote: > Hi there > > *Version 2.20-SNAPSHOT, Build #19453* > > Trying to update a TrackedEntityInstance but this is failing for > attributes that have an optionSet assigned. > > I've stripped my JSON update down to a single attribute. > > > *API call:* > > PUT http://localhost:8000/api/trackedEntityInstances/gGCuCUO5Iu0 > > > *JSON: Here's the json I'm sending for the update:* > > { > "trackedEntity":"An3UR3eaTTa", > "orgUnit":"FEGZA6BEAjj", > "attributes":[ > {"attribute":"kxvbQMX8Yss","value":"3"} > ] > } > > > *Here's the TrackedEntityAttribute:* > > { > > - id: "kxvbQMX8Yss", > - created: "2015-06-18T22:27:51.242+0000", > - name: "DHS 2010 - sample domain", > - href: "http://localhost:8000/api/trackedEntityAttributes/kxvbQMX8Yss" > , > - lastUpdated: "2015-06-18T22:27:51.286+0000", > - code: "DHS 2010 - v023", > - shortName: "DHS 2010 - sample domain", > - displayDescription: "sample domain", > - unique: false, > - programScope: false, > - displayInListNoProgram: false, > - orgunitScope: false, > - displayOnVisitSchedule: false, > - dataDimension: true, > - description: "sample domain", > - externalAccess: false, > - valueType: "optionSet", > - confidential: false, > - publicAccess: "rw------", > - allItems: false, > - inherit: false, > - dimension: "kxvbQMX8Yss", > - optionSetValue: true, > - displayName: "DHS 2010 - sample domain", > - displayShortName: "DHS 2010 - sample domain", > - optionSet: > { > - id: "CnFzpGPWbJg", > - name: "DHS 2010 - sample domain", > - code: "DHS 2010 - v023", > - created: "2015-06-18T22:27:51.101+0000", > - lastUpdated: "2015-06-18T23:51:10.981+0000", > - href: "http://localhost:8000/api/optionSets/CnFzpGPWbJg" > }, > - access: > { > - update: true, > - externalize: false, > - write: true, > - delete: true, > - read: true, > - manage: true > }, > - user: > { > - id: "M4XhsWJlIhk", > - name: "admin admin", > - created: "2015-06-18T15:26:06.062+0000", > - lastUpdated: "2015-06-18T16:07:29.473+0000", > - href: "http://localhost:8000/api/users/M4XhsWJlIhk" > }, > - attributeValues: [ ], > - items: [ ], > - userGroupAccesses: [ ] > > } > > *Here's the OptionSet:* > > { > > - lastUpdated: "2015-06-18T23:51:10.981+0000", > - code: "DHS 2010 - v023", > - id: "CnFzpGPWbJg", > - created: "2015-06-18T22:27:51.101+0000", > - name: "DHS 2010 - sample domain", > - href: "http://localhost:8000/api/optionSets/CnFzpGPWbJg", > - publicAccess: "rw------", > - version: 0, > - externalAccess: false, > - displayName: "DHS 2010 - sample domain", > - access: > { > - update: true, > - externalize: false, > - write: true, > - delete: true, > - read: true, > - manage: true > }, > - user: > { > - id: "M4XhsWJlIhk", > - name: "admin admin", > - created: "2015-06-18T15:26:06.062+0000", > - lastUpdated: "2015-06-18T16:07:29.473+0000", > - href: "http://localhost:8000/api/users/M4XhsWJlIhk" > }, > - userGroupAccesses: [ ], > - options: > [ > - > { > - id: "Fnkf3CXYjtU", > - name: "northern", > - code: "1", > - created: "2015-06-18T22:27:50.583+0000", > - lastUpdated: "2015-06-18T23:51:10.554+0000", > - href: "http://localhost:8000/api/options/Fnkf3CXYjtU" > }, > - > { > - id: "p6xLuMAZ6Kx", > - name: "central", > - code: "2", > - created: "2015-06-18T22:27:50.720+0000", > - lastUpdated: "2015-06-18T23:51:10.675+0000", > - href: "http://localhost:8000/api/options/p6xLuMAZ6Kx" > }, > - > { > - id: "XJa5QiUzKgb", > - name: "southern", > - code: "3", > - created: "2015-06-18T22:27:50.910+0000", > - lastUpdated: "2015-06-18T23:51:10.803+0000", > - href: "http://localhost:8000/api/options/XJa5QiUzKgb" > } > ] > > } > > However, this fails and I see an exception in tomcat logs: > > SEVERE: Servlet.service() for servlet [webapi] in context with path [] > threw exception [Request processing failed; nested exception is > java.lang.NullPointerException] with root cause > java.lang.NullPointerException > at > org.hisp.dhis.trackedentity.TrackedEntityAttribute.isValidOptionValue(TrackedEntityAttribute.java:162) > at > org.hisp.dhis.dxf2.events.trackedentity.AbstractTrackedEntityInstanceService.validateAttributeType(AbstractTrackedEntityInstanceService.java:582) > at > org.hisp.dhis.dxf2.events.trackedentity.AbstractTrackedEntityInstanceService.checkAttributes(AbstractTrackedEntityInstanceService.java:404) > at > org.hisp.dhis.dxf2.events.trackedentity.AbstractTrackedEntityInstanceService.updateTrackedEntityInstance(AbstractTrackedEntityInstanceService.java:293) > at > org.hisp.dhis.dxf2.events.trackedentity.JacksonTrackedEntityInstanceService.updateTrackedEntityInstanceJson(JacksonTrackedEntityInstanceService.java:198) > at sun.reflect.GeneratedMethodAccessor895.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:606) > at > org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) > ... > > > Any advice greatly appreciated. > > Thanks > > Alan > > > _______________________________________________ > Mailing list: https://launchpad.net/~dhis2-devs > Post to : [email protected] > Unsubscribe : https://launchpad.net/~dhis2-devs > More help : https://help.launchpad.net/ListHelp > >
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : [email protected] Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp

