dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38288
Re: Problem Posting to XML to Web API
To follow up I just discovered why it wasn’t working I had a typo in the URL, though the error was a bit misleading.
> On Jun 30, 2015, at 1:44 PM, Dan Cocos <dan@xxxxxxxxxxxx> wrote:
>
>
> I still get an error when I try with the following, I’ve attached a copy of the complete stack trace.
>
> <organisationUnit id="IheTV7ihHgI" level="6" name="Test2" shortName="TEST2" xmlns="http://dhis2.org/schema/dxf/2.0 <http://dhis2.org/schema/dxf/2.0>">
> <externalAccess>false</externalAccess>
> <openingDate>2015-05-20T23:00:00.000+0000</openingDate>
> <displayName>BAO Test</displayName>
> <parent id="Iu06qlak3ZY" />
> </organisationUnit>
>
> or this
>
> <organisationUnit id="IheTV7ihHgI" level="6" name="Test" shortName="TEST" xmlns="http://dhis2.org/schema/dxf/2.0 <http://dhis2.org/schema/dxf/2.0>">
> <externalAccess>false</externalAccess>
> <openingDate>2015-05-20T23:00:00.000+0000</openingDate>
> <displayName>BAO Test</displayName>
> <parent id="OqNfa8dQ546" />
> <users/>
> <organisationUnitGroups/>
> <children/>
> <dataSets/>
> <userGroupAccesses/>
> </organisationUnit>
>
> <error.html>
>
>> On Jun 30, 2015, at 1:24 PM, Dan Cocos <dan@xxxxxxxxxxxx <mailto:dan@xxxxxxxxxxxx>> wrote:
>>
>> Thank you!
>> I’ve also found that trying to delete OUs via the API causes a 504 Request method 'DELETE' not supported
>> Are we not able to delete OUs via the API?
>>
>>
>>> On Jun 30, 2015, at 1:15 PM, Halvdan Grelland <halvdanhg@xxxxxxxxx <mailto:halvdanhg@xxxxxxxxx>> wrote:
>>>
>>> Hi Dan,
>>>
>>> I was able to reproduce the issue on our demo server. It seems to be due to the empty attributevalues-element. Removing it caused the import to work as expected. Why this is, however, I do not know. We are currently looking into a separate AttributeValue-related issue with the importer, which could be related.
>>>
>>> ---
>>>
>>> Att: Morten:
>>>
>>> The interesting part of the stack trace:
>>>
>>> </pre></p><p><b>root cause</b> <pre>java.lang.NullPointerException
>>> org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter$NonIdentifiableObjects.extractAttributeValues(DefaultIdentifiableObjectImporter.java:1121)
>>> org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter$NonIdentifiableObjects.extract(DefaultIdentifiableObjectImporter.java:944)
>>> org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.newObject(DefaultIdentifiableObjectImporter.java:305)
>>> org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.startImport(DefaultIdentifiableObjectImporter.java:525)
>>> org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.importObjectLocal(DefaultIdentifiableObjectImporter.java:511)
>>> org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.importObject(DefaultIdentifiableObjectImporter.java:210)
>>> org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.importObject(DefaultIdentifiableObjectImporter.java:102)
>>> org.hisp.dhis.dxf2.metadata.DefaultImportService.doImport(DefaultImportService.java:281)
>>> org.hisp.dhis.dxf2.metadata.DefaultImportService.importObject(DefaultImportService.java:115)
>>>
>>> Regards,
>>> Halvdan
>>>
>>> 2015-06-30 19:05 GMT+02:00 Dan Cocos <dan@xxxxxxxxxxxx <mailto:dan@xxxxxxxxxxxx>>:
>>> Hi All,
>>>
>>> I’m trying to post a simple XML file to create an OU the following is curl call and the contents of the file (ou.xml)
>>>
>>> curl -d @ou.xml "https://example.com/api/organistaionUnits <https://example.com/api/organistaionUnits>" -X POST -H "Content-Type: application/xml" -u admin:district
>>>
>>> <organisationUnit id="IheTV7ihHgI" level="6" name="Test" shortName="TEST" xmlns="http://dhis2.org/schema/dxf/2.0 <http://dhis2.org/schema/dxf/2.0>">
>>> <externalAccess>false</externalAccess>
>>> <openingDate>2015-05-20T23:00:00.000+0000</openingDate>
>>> <displayName>Test</displayName>
>>> <parent id="OqNfa8dQ546" />
>>> <users/>
>>> <organisationUnitGroups/>
>>> <children/>
>>> <dataSets/>
>>> <attributeValues/>
>>> <userGroupAccesses/>
>>> </organisationUnit>
>>>
>>> The server response is:
>>> org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
>>>
>>>
>>> Does anyone have a working example of posting OUs to the web API?
>>>
>>> Thank you,
>>> Dan
>>>
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dhis2-devs <https://launchpad.net/~dhis2-devs>
>>> Post to : dhis2-devs@xxxxxxxxxxxxxxxxxxx <mailto:dhis2-devs@xxxxxxxxxxxxxxxxxxx>
>>> Unsubscribe : https://launchpad.net/~dhis2-devs <https://launchpad.net/~dhis2-devs>
>>> More help : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
>>>
>>
>
Follow ups
References