Errors importing Events in 2.15 using the Web API (or maybe I am doing something wrong)

Dear Dev community

I am trying to import several events to DHIS2 (2.15) using the Web API. This is a template of the XML file (note I am using the org. unit code for matching):

<?xml version="1.0"?>
	<event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">

	<dataValues>

	<dataValue dataElement="sQdFlFQptCX" value="34"/>

	<dataValue dataElement="gVqInPr2eqC" value="30-34"/>

	<dataValue dataElement="hjy1KTANQbl" value="Unknown"/>

	<dataValue dataElement="es3zQNdcN7d" value="4"/>

When I call the API, I get the following error: “Event.orgUnit does not point to a valid organisation unit”. So, following the documentation I added the attribute orgUnitIdScheme=“code”, something like the following: However, in this case I am getting: "HTTP Status 500 - Unrecognized field “orgUnitIdScheme”.

Also as I have to send multiple events, I am using the schema:

<?xml version="1.0"?>
<eventList>

	<event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">

	<dataValues>

but in this case the error I got is "HTTP Status 500 - Unrecognized field “eventList”

Am I missing something? I tried to use the Import/Export app as well, but nothing was imported.

I am using the 2.15 with the build revision 15201

Many thanks

Jose

Hi

The id scheme must be added to the url, and not the actual payload…

···


Morten

On Thu, Aug 14, 2014 at 4:58 AM, Jose Garcia Muñoz josemp10@gmail.com wrote:

Dear Dev community

I am trying to import several events to DHIS2 (2.15) using the Web API. This is a template of the XML file (note I am using the org. unit code for matching):

<?xml version="1.0"?>
  <event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">
  <dataValues>
  <dataValue dataElement="sQdFlFQptCX" value="34"/>
  <dataValue dataElement="gVqInPr2eqC" value="30-34"/>
  <dataValue dataElement="hjy1KTANQbl" value="Unknown"/>
  <dataValue dataElement="es3zQNdcN7d" value="4"/>

When I call the API, I get the following error: “Event.orgUnit does not point to a valid organisation unit”. So, following the documentation I added the attribute orgUnitIdScheme=“code”, something like the following: However, in this case I am getting: "HTTP Status 500 - Unrecognized field “orgUnitIdScheme”.

Also as I have to send multiple events, I am using the schema:

<?xml version="1.0"?>
  <event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">
  <dataValues>

but in this case the error I got is "HTTP Status 500 - Unrecognized field “eventList”

Am I missing something? I tried to use the Import/Export app as well, but nothing was imported.

I am using the 2.15 with the build revision 15201

Many thanks

Jose


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Ups… thanks Morten. Now it is working fine for one event. Thank you.

what about sending multiple events? I am still getting " HTTP Status 500 - Unrecognized field “eventList” "

···

On Thu, Aug 14, 2014 at 7:10 AM, Morten Olav Hansen mortenoh@gmail.com wrote:

Hi

The id scheme must be added to the url, and not the actual payload…


Morten

On Thu, Aug 14, 2014 at 4:58 AM, Jose Garcia Muñoz josemp10@gmail.com wrote:

Dear Dev community

I am trying to import several events to DHIS2 (2.15) using the Web API. This is a template of the XML file (note I am using the org. unit code for matching):

<?xml version="1.0"?>
  <event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">
  <dataValues>
  <dataValue dataElement="sQdFlFQptCX" value="34"/>
  <dataValue dataElement="gVqInPr2eqC" value="30-34"/>
  <dataValue dataElement="hjy1KTANQbl" value="Unknown"/>
  <dataValue dataElement="es3zQNdcN7d" value="4"/>

When I call the API, I get the following error: “Event.orgUnit does not point to a valid organisation unit”. So, following the documentation I added the attribute orgUnitIdScheme=“code”, something like the following: However, in this case I am getting: "HTTP Status 500 - Unrecognized field “orgUnitIdScheme”.

Also as I have to send multiple events, I am using the schema:

<?xml version="1.0"?>
  <event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">
  <dataValues>

but in this case the error I got is "HTTP Status 500 - Unrecognized field “eventList”

Am I missing something? I tried to use the Import/Export app as well, but nothing was imported.

I am using the 2.15 with the build revision 15201

Many thanks

Jose


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Sorry, the xml format has changed a bit… you don’t require a eventList anymore…

You can just do:

···


Morten

On Thu, Aug 14, 2014 at 3:35 PM, Jose Garcia Muñoz josemp10@gmail.com wrote:

Ups… thanks Morten. Now it is working fine for one event. Thank you.

what about sending multiple events? I am still getting " HTTP Status 500 - Unrecognized field “eventList” "

On Thu, Aug 14, 2014 at 7:10 AM, Morten Olav Hansen mortenoh@gmail.com wrote:

Hi

The id scheme must be added to the url, and not the actual payload…


Morten

On Thu, Aug 14, 2014 at 4:58 AM, Jose Garcia Muñoz josemp10@gmail.com wrote:

Dear Dev community

I am trying to import several events to DHIS2 (2.15) using the Web API. This is a template of the XML file (note I am using the org. unit code for matching):

<?xml version="1.0"?>
  <event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">
  <dataValues>
  <dataValue dataElement="sQdFlFQptCX" value="34"/>
  <dataValue dataElement="gVqInPr2eqC" value="30-34"/>
  <dataValue dataElement="hjy1KTANQbl" value="Unknown"/>
  <dataValue dataElement="es3zQNdcN7d" value="4"/>

When I call the API, I get the following error: “Event.orgUnit does not point to a valid organisation unit”. So, following the documentation I added the attribute orgUnitIdScheme=“code”, something like the following: However, in this case I am getting: "HTTP Status 500 - Unrecognized field “orgUnitIdScheme”.

Also as I have to send multiple events, I am using the schema:

<?xml version="1.0"?>
  <event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">
  <dataValues>

but in this case the error I got is "HTTP Status 500 - Unrecognized field “eventList”

Am I missing something? I tried to use the Import/Export app as well, but nothing was imported.

I am using the 2.15 with the build revision 15201

Many thanks

Jose


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Thanks Morten,

This is the template I use

<?xml version="1.0"?>
<event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">

	<dataValues>

	<dataValue dataElement="sQdFlFQptCX" value="34"/>

	</dataValues>

</event>

<event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">

	<dataValues>

	<dataValue dataElement="sQdFlFQptCX" value="20"/>

	</dataValues>

Now I get the error: HTTP Status 500 - Can not deserialize instance of java.lang.String out of START_OBJECT token

···

On Thu, Aug 14, 2014 at 10:38 AM, Morten Olav Hansen mortenoh@gmail.com wrote:

Sorry, the xml format has changed a bit… you don’t require a eventList anymore…

You can just do:


Morten

On Thu, Aug 14, 2014 at 3:35 PM, Jose Garcia Muñoz josemp10@gmail.com wrote:

Ups… thanks Morten. Now it is working fine for one event. Thank you.

what about sending multiple events? I am still getting " HTTP Status 500 - Unrecognized field “eventList” "

On Thu, Aug 14, 2014 at 7:10 AM, Morten Olav Hansen mortenoh@gmail.com wrote:

Hi

The id scheme must be added to the url, and not the actual payload…


Morten

On Thu, Aug 14, 2014 at 4:58 AM, Jose Garcia Muñoz josemp10@gmail.com wrote:

Dear Dev community

I am trying to import several events to DHIS2 (2.15) using the Web API. This is a template of the XML file (note I am using the org. unit code for matching):

<?xml version="1.0"?>
  <event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">
  <dataValues>
  <dataValue dataElement="sQdFlFQptCX" value="34"/>
  <dataValue dataElement="gVqInPr2eqC" value="30-34"/>
  <dataValue dataElement="hjy1KTANQbl" value="Unknown"/>
  <dataValue dataElement="es3zQNdcN7d" value="4"/>

When I call the API, I get the following error: “Event.orgUnit does not point to a valid organisation unit”. So, following the documentation I added the attribute orgUnitIdScheme=“code”, something like the following: However, in this case I am getting: "HTTP Status 500 - Unrecognized field “orgUnitIdScheme”.

Also as I have to send multiple events, I am using the schema:

<?xml version="1.0"?>
  <event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">
  <dataValues>

but in this case the error I got is "HTTP Status 500 - Unrecognized field “eventList”

Am I missing something? I tried to use the Import/Export app as well, but nothing was imported.

I am using the 2.15 with the build revision 15201

Many thanks

Jose


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Can you give me the full stack trace? also remember to add namespace

···


Morten

On Thu, Aug 14, 2014 at 3:54 PM, Jose Garcia Muñoz josemp10@gmail.com wrote:

Thanks Morten,

This is the template I use

<?xml version="1.0"?>
  <dataValues>
  <dataValue dataElement="sQdFlFQptCX" value="34"/>

  </dataValues>
  <dataValues>
  <dataValue dataElement="sQdFlFQptCX" value="20"/>

  </dataValues>

Now I get the error: HTTP Status 500 - Can not deserialize instance of java.lang.String out of START_OBJECT token

On Thu, Aug 14, 2014 at 10:38 AM, Morten Olav Hansen mortenoh@gmail.com wrote:

Sorry, the xml format has changed a bit… you don’t require a eventList anymore…

You can just do:


Morten

On Thu, Aug 14, 2014 at 3:35 PM, Jose Garcia Muñoz josemp10@gmail.com wrote:

Ups… thanks Morten. Now it is working fine for one event. Thank you.

what about sending multiple events? I am still getting " HTTP Status 500 - Unrecognized field “eventList” "

On Thu, Aug 14, 2014 at 7:10 AM, Morten Olav Hansen mortenoh@gmail.com wrote:

Hi

The id scheme must be added to the url, and not the actual payload…


Morten

On Thu, Aug 14, 2014 at 4:58 AM, Jose Garcia Muñoz josemp10@gmail.com wrote:

Dear Dev community

I am trying to import several events to DHIS2 (2.15) using the Web API. This is a template of the XML file (note I am using the org. unit code for matching):

<?xml version="1.0"?>
  <event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">
  <dataValues>
  <dataValue dataElement="sQdFlFQptCX" value="34"/>
  <dataValue dataElement="gVqInPr2eqC" value="30-34"/>
  <dataValue dataElement="hjy1KTANQbl" value="Unknown"/>
  <dataValue dataElement="es3zQNdcN7d" value="4"/>

When I call the API, I get the following error: “Event.orgUnit does not point to a valid organisation unit”. So, following the documentation I added the attribute orgUnitIdScheme=“code”, something like the following: However, in this case I am getting: "HTTP Status 500 - Unrecognized field “orgUnitIdScheme”.

Also as I have to send multiple events, I am using the schema:

<?xml version="1.0"?>
  <event program="FurLapSaYy4" orgUnit="TZPSI_P-1563" eventDate="2014-01-01" status="COMPLETED" storedBy="jose">
  <dataValues>

but in this case the error I got is "HTTP Status 500 - Unrecognized field “eventList”

Am I missing something? I tried to use the Import/Export app as well, but nothing was imported.

I am using the 2.15 with the build revision 15201

Many thanks

Jose


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Here it goes. Thanks. I have added the namespace with the same result.

C:\Program Files\cURL\bin>curl.exe -d @c:\Users\Jose\PSI\testTZ.xml "https://dev2.psi-mis.org/api/events?orgUnitIdScheme=code

" -H “Content-Type:application/xml” -u myuser:mypass -v

  • Hostname was NOT found in DNS cache

  • Adding handle: conn: 0xe05248

  • Adding handle: send: 0

  • Adding handle: recv: 0

  • Curl_addHandleToPipeline: length: 1

    • Conn 0 (0xe05248) send_pipe: 1, recv_pipe: 0
  • Trying 107.170.109.182…

  • Connected to dev2.psi-mis.org (107.170.109.182) port 443 (#0)

  • successfully set certificate verify locations:

  • CAfile: C:\Program Files\cURL\bin\curl-ca-bundle.crt

CApath: none

  • SSLv3, TLS handshake, Client hello (1):

  • SSLv3, TLS handshake, Server hello (2):

  • SSLv3, TLS handshake, CERT (11):

  • SSLv3, TLS handshake, Server finished (14):

  • SSLv3, TLS handshake, Client key exchange (16):

  • SSLv3, TLS change cipher, Client hello (1):

  • SSLv3, TLS handshake, Finished (20):

  • SSLv3, TLS change cipher, Client hello (1):

  • SSLv3, TLS handshake, Finished (20):

  • SSL connection using RC4-SHA

  • Server certificate:

OU=Domain Control Validated - RapidSSL(R); CN=*.psi-mis.org

  •    start date: 2014-05-10 14:40:48 GMT
    
  •    expire date: 2015-06-13 11:02:37 GMT
    
  •    subjectAltName: [dev2.psi-mis.org](http://dev2.psi-mis.org) matched
    
  •    issuer: C=US; O=GeoTrust, Inc.; CN=RapidSSL CA
    
  •    SSL certificate verify ok.
    
  • Server auth using Basic with user ‘jose’

POST /api/events?orgUnitIdScheme=code HTTP/1.1

Authorization: Basic am9zZTpKR00yMDE0eHg=

User-Agent: curl/7.34.0

Host: dev2.psi-mis.org

Accept: /

Content-Type:application/xml

Content-Length: 1484

Expect: 100-continue

< HTTP/1.1 100 Continue

< HTTP/1.1 500 Internal Server Error

  • Server nginx is not blacklisted

< Server: nginx

< Date: Thu, 14 Aug 2014 09:05:23 GMT

< Content-Type: text/html;charset=utf-8

< Transfer-Encoding: chunked

< Connection: keep-alive

  • HTTP error before end of send, stop sending

<

Apache Tomcat/7.0.39 - Error report

Its hard to say exactly what’s wrong here… but can you send me the file as an attachment? it is complaining about the format of the file, so there must be something there… probably something

···


Morten

On Thu, Aug 14, 2014 at 4:08 PM, Jose Garcia Muñoz josemp10@gmail.com wrote:

Here it goes. Thanks. I have added the namespace with the same result.

C:\Program Files\cURL\bin>curl.exe -d @c:\Users\Jose\PSI\testTZ.xml "https://dev2.psi-mis.org/api/events?orgUnitIdScheme=code

" -H “Content-Type:application/xml” -u myuser:mypass -v

  • Hostname was NOT found in DNS cache
  • Adding handle: conn: 0xe05248
  • Adding handle: send: 0
  • Adding handle: recv: 0
  • Curl_addHandleToPipeline: length: 1
    • Conn 0 (0xe05248) send_pipe: 1, recv_pipe: 0
  • Trying 107.170.109.182…
  • successfully set certificate verify locations:
  • CAfile: C:\Program Files\cURL\bin\curl-ca-bundle.crt

CApath: none

  • SSLv3, TLS handshake, Client hello (1):
  • SSLv3, TLS handshake, Server hello (2):
  • SSLv3, TLS handshake, CERT (11):
  • SSLv3, TLS handshake, Server finished (14):
  • SSLv3, TLS handshake, Client key exchange (16):
  • SSLv3, TLS change cipher, Client hello (1):
  • SSLv3, TLS handshake, Finished (20):
  • SSLv3, TLS change cipher, Client hello (1):
  • SSLv3, TLS handshake, Finished (20):
  • SSL connection using RC4-SHA
  • Server certificate:
  •    subject: serialNumber=vXzmodpZ3BxUINTU1qnaoJo0cbAA/PpJ; OU=GT94607079; OU=See [www.rapidssl.com/resources/cps](http://www.rapidssl.com/resources/cps) (c)14;
    

OU=Domain Control Validated - RapidSSL(R); CN=*.psi-mis.org

  •    start date: 2014-05-10 14:40:48 GMT
    
  •    expire date: 2015-06-13 11:02:37 GMT
    
  •    subjectAltName: [dev2.psi-mis.org](http://dev2.psi-mis.org) matched
    
  •    issuer: C=US; O=GeoTrust, Inc.; CN=RapidSSL CA
    
  •    SSL certificate verify ok.
    
  • Server auth using Basic with user ‘jose’

POST /api/events?orgUnitIdScheme=code HTTP/1.1

Authorization: Basic am9zZTpKR00yMDE0eHg=

User-Agent: curl/7.34.0

Host: dev2.psi-mis.org

Accept: /

Content-Type:application/xml

Content-Length: 1484

Expect: 100-continue

< HTTP/1.1 100 Continue

< HTTP/1.1 500 Internal Server Error

  • Server nginx is not blacklisted

< Server: nginx

< Date: Thu, 14 Aug 2014 09:05:23 GMT

< Content-Type: text/html;charset=utf-8

< Transfer-Encoding: chunked

< Connection: keep-alive

  • HTTP error before end of send, stop sending

<

Apache Tomcat/7.0.39 - Error report

Great! It is working now! Thanks Morten

···

On Fri, Aug 15, 2014 at 11:08 AM, Morten Olav Hansen mortenoh@gmail.com wrote:

Hi

This file is working fine in 2.16/trunk, sorry for telling you something wrong, but since you are using an old version, you do actually need the old way of doing this… which is:

This is due to a missing feature in the library we used for 2.15, it was fixed in 2.16 and version going forward does not require this double element


Morten

On Fri, Aug 15, 2014 at 4:02 PM, Jose Garcia Muñoz josemp10@gmail.com wrote:

Here it goes…

We can set up an account for you in our dev server in case you need some testing.

Many thanks Morten

On Fri, Aug 15, 2014 at 10:11 AM, Morten Olav Hansen mortenoh@gmail.com wrote:

Its hard to say exactly what’s wrong here… but can you send me the file as an attachment? it is complaining about the format of the file, so there must be something there… probably something


Morten

On Thu, Aug 14, 2014 at 4:08 PM, Jose Garcia Muñoz josemp10@gmail.com wrote:

Here it goes. Thanks. I have added the namespace with the same result.

C:\Program Files\cURL\bin>curl.exe -d @c:\Users\Jose\PSI\testTZ.xml "https://dev2.psi-mis.org/api/events?orgUnitIdScheme=code

" -H “Content-Type:application/xml” -u myuser:mypass -v

  • Hostname was NOT found in DNS cache
  • Adding handle: conn: 0xe05248
  • Adding handle: send: 0
  • Adding handle: recv: 0
  • Curl_addHandleToPipeline: length: 1
    • Conn 0 (0xe05248) send_pipe: 1, recv_pipe: 0
  • Trying 107.170.109.182…
  • successfully set certificate verify locations:
  • CAfile: C:\Program Files\cURL\bin\curl-ca-bundle.crt

CApath: none

  • SSLv3, TLS handshake, Client hello (1):
  • SSLv3, TLS handshake, Server hello (2):
  • SSLv3, TLS handshake, CERT (11):
  • SSLv3, TLS handshake, Server finished (14):
  • SSLv3, TLS handshake, Client key exchange (16):
  • SSLv3, TLS change cipher, Client hello (1):
  • SSLv3, TLS handshake, Finished (20):
  • SSLv3, TLS change cipher, Client hello (1):
  • SSLv3, TLS handshake, Finished (20):
  • SSL connection using RC4-SHA
  • Server certificate:
  •    subject: serialNumber=vXzmodpZ3BxUINTU1qnaoJo0cbAA/PpJ; OU=GT94607079; OU=See [www.rapidssl.com/resources/cps](http://www.rapidssl.com/resources/cps) (c)14;
    

OU=Domain Control Validated - RapidSSL(R); CN=*.psi-mis.org

  •    start date: 2014-05-10 14:40:48 GMT
    
  •    expire date: 2015-06-13 11:02:37 GMT
    
  •    subjectAltName: [dev2.psi-mis.org](http://dev2.psi-mis.org) matched
    
  •    issuer: C=US; O=GeoTrust, Inc.; CN=RapidSSL CA
    
  •    SSL certificate verify ok.
    
  • Server auth using Basic with user ‘jose’

POST /api/events?orgUnitIdScheme=code HTTP/1.1

Authorization: Basic am9zZTpKR00yMDE0eHg=

User-Agent: curl/7.34.0

Host: dev2.psi-mis.org

Accept: /

Content-Type:application/xml

Content-Length: 1484

Expect: 100-continue

< HTTP/1.1 100 Continue

< HTTP/1.1 500 Internal Server Error

  • Server nginx is not blacklisted

< Server: nginx

< Date: Thu, 14 Aug 2014 09:05:23 GMT

< Content-Type: text/html;charset=utf-8

< Transfer-Encoding: chunked

< Connection: keep-alive

  • HTTP error before end of send, stop sending

<

Apache Tomcat/7.0.39 - Error report