← Back to team overview

dhis2-devs team mailing list archive

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

 

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:
*        subject: serialNumber=vXzmodpZ3BxUINTU1qnaoJo0cbAA/PpJ;
OU=GT94607079; OU=See 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 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
<
<html><head><title>Apache Tomcat/7.0.39 - Error report</title><style><!--H1
{font-family:Tahoma,Arial,sans-serif;color:white;
background-color:#525D76;font-size:22px;} H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-s
ize:16px;} H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
BODY {font-family:Ta
homa,Arial,sans-serif;color:black;background-color:white;} B
{font-family:Tahoma,Arial,sans-serif;color:white;background-colo
r:#525D76;} P
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
{color : black;}A.name {col
or : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status
500 - Can not deserialize instance of java.lang.Str
ing out of START_OBJECT token</h1><HR size="1"
noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b>
<u>Can
not deserialize instance of java.lang.String out of START_OBJECT
token</u></p><p><b>description</b> <u>The server encountered
 an internal error that prevented it from fulfilling this
request.</u></p><p><b>exception</b> <pre>com.fasterxml.jackson.data
bind.JsonMappingException: Can not deserialize instance of java.lang.String
out of START_OBJECT token
 at [Source: java.io.StringReader@372d828; line: 1, column: 71] (through
reference chain: org.hisp.dhis.dxf2.events.event.Eve
nt[&quot;event&quot;])

com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:163)

com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:588)

com.fasterxml.jackson.databind.deser.std.JdkDeserializers$StringDeserializer.deserialize(JdkDeserializers.java:90)

com.fasterxml.jackson.databind.deser.std.JdkDeserializers$StringDeserializer.deserialize(JdkDeserializers.java:59)

com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:336)

com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:89)

com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:290)

com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:112)

com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2580)

com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1810)

org.hisp.dhis.dxf2.events.event.JacksonEventService.fromXml(JacksonEventService.java:86)

org.hisp.dhis.dxf2.events.event.JacksonEventService.addEventsXml(JacksonEventService.java:155)

org.hisp.dhis.dxf2.events.event.JacksonEventService.addEventsXml(JacksonEventService.java:120)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.lang.reflect.Method.invoke(Method.java:606)

org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)

org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)

org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)

org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.jav
a:96)

org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport
.java:260)

org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)

org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        com.sun.proxy.$Proxy131.addEventsXml(Unknown Source)

org.hisp.dhis.api.controller.event.EventController.postXmlEvent(EventController.java:259)

org.hisp.dhis.api.controller.event.EventController$$FastClassByCGLIB$$e5ad859e.invoke(&lt;generated&gt;)

org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)

org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:701)

org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)

org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.
java:64)

org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:634)

org.hisp.dhis.api.controller.event.EventController$$EnhancerByCGLIB$$6471438a.postXmlEvent(&lt;generated&gt;)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.lang.reflect.Method.invoke(Method.java:606)

org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)

org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)

org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableH
andlerMethod.java:104)

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingH
andlerAdapter.java:745)

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandl
erAdapter.java:686)

org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)

org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)

org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)

org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)

org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:647)

org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:202)

net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:180)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)

org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118
)

org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:8
4)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.
java:113)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwa
reRequestFilter.java:54)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java
:201)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticatio
nProcessingFilter.java:183)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticatio
nProcessingFilter.java:183)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.hisp.dhis.security.filter.CustomAuthenticationFilter.doFilter(CustomAuthenticationFilter.java:64)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.hisp.dhis.security.filter.AutomaticAccessFilter.doFilter(AutomaticAccessFilter.java:113)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.j
ava:87)

org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)

org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)

org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)

org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)

org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:149)


org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is
available in the Apache Tomcat/7.0.39 logs.</u></p><HR
size="1" noshade="noshade"><h3>Apache Tomcat/7.0.39</h3></body></html>*
Closing connection 0
* SSLv3, TLS alert, Client hello (1):


On Thu, Aug 14, 2014 at 10:55 AM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
wrote:

> 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@xxxxxxxxx>
> wrote:
>
>>
>> Thanks Morten,
>>
>> This is the template I use
>>
>> <?xml version="1.0"?>
>> <events>
>>  <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>
>>          </event>
>> </events>
>>
>> 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@xxxxxxxxx>
>> wrote:
>>
>>> Sorry, the xml format has changed a bit.. you don't require a eventList
>>> anymore..
>>>
>>> You can just do:
>>> <events>
>>>   <event> ... </event>
>>>   <event> ... </event>
>>>   <event> ... </event>
>>> </events>
>>>
>>> --
>>> Morten
>>>
>>>
>>> On Thu, Aug 14, 2014 at 3:35 PM, Jose Garcia Muñoz <josemp10@xxxxxxxxx>
>>> 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@xxxxxxxxx
>>>> > 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@xxxxxxxxx
>>>>> > 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"/>
>>>>>>                </dataValues>
>>>>>> </event>
>>>>>>
>>>>>> 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: <event program="FurLapSaYy4" orgUnit="TZPSI_P-1563"
>>>>>> eventDate="2014-01-01" status="COMPLETED" orgUnitIdScheme="code"
>>>>>> storedBy="jose"> 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"?><events>
>>>>>> <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
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Follow ups

References