dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30954
Re: Importing OrgUnit data via API using curl
Hi Lars,
Here we go.
------------------------------------
today=$(date +"%d-%m-%Y") && mfl=${today}_mfl.xml && dxf=${today}_dxf.xml
&& cd /home/dhis/logs && /usr/bin/curl "
http://api.ehealth.or.ke/http/getlastnfacilities.aspx?username=admin&password=xxxxx&count=10"
| xmlindent > "$mfl" && more
$mfl | xsltproc /home/dhis/config/transform/mfl2dxf2.xsl - > "$dxf" && echo
-e "Latest sync from MFL to DHIS2:" $(date) "\n" > latest.xml && more $dxf
>> latest.xml && /usr/bin/curl -X POST -H "Content-Type:application/xml" -u
dmuturi:xxxxxxx -d @$dxf "https://hiskenya.org/api/metaData"
----------------------------------
rgds
David
2014-06-16 16:10 GMT+03:00 Lars Helge Øverland <larshelge@xxxxxxxxx>:
> Hi David,
>
> do you think you could post your curl command?
>
> Lars
>
>
>
>
> On Thu, Jun 12, 2014 at 9:41 AM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
> wrote:
>
>> Did you set the content-type header? it's either that, or something is
>> wrong with your data
>>
>> --
>> Morten
>>
>>
>> On Thu, Jun 12, 2014 at 9:37 AM, David Muturi <dnmuturi@xxxxxxxxx> wrote:
>>
>>> Hi Team,
>>> I am importing org unit data via the api using curl, on running the
>>> script, this is the error I am getting. Anyone who has done this before and
>>> has an idea what could be wrong ? I am doing this on DHIS 2.13
>>>
>>> ------------------------------------------------------------------------------------------------------
>>> <html><head><title>Apache Tomcat/7.0.42 - 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-size:16px;}
>>> H3
>>> {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
>>> BODY
>>> {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B
>>> {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
>>> P
>>> {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
>>> {color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
>>> </head><body><h1>HTTP Status 500 -
>>> com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '1'
>>> (code 49) in prolog; expected '<'</h1><HR size="1"
>>> noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b>
>>> <u>com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '1'
>>> (code 49) in prolog; expected '<'</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>java.io.IOException:
>>> com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '1'
>>> (code 49) in prolog; expected '<'
>>> at [row,col {unknown-source}]: [1,46]
>>>
>>> com.fasterxml.jackson.dataformat.xml.util.StaxUtil.throwXmlAsIOException(StaxUtil.java:24)
>>>
>>> com.fasterxml.jackson.dataformat.xml.XmlFactory._createJsonParser(XmlFactory.java:360)
>>>
>>> com.fasterxml.jackson.dataformat.xml.XmlFactory._createJsonParser(XmlFactory.java:27)
>>>
>>> com.fasterxml.jackson.core.JsonFactory.createJsonParser(JsonFactory.java:558)
>>>
>>> com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1856)
>>>
>>> org.hisp.dhis.dxf2.utils.JacksonUtils.fromXml(JacksonUtils.java:202)
>>>
>>> org.hisp.dhis.api.controller.MetaDataController.importXml(MetaDataController.java:228)
>>>
>>> org.hisp.dhis.api.controller.MetaDataController$$FastClassByCGLIB$$6089c6af.invoke(<generated>)
>>>
>>> org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
>>>
>>> org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
>>>
>>> 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:631)
>>>
>>> org.hisp.dhis.api.controller.MetaDataController$$EnhancerByCGLIB$$c31baab2.importXml(<generated>)
>>> 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(ServletInvocableHandlerMethod.java:104)
>>>
>>> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
>>>
>>> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.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)
>>>
>>> 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:84)
>>>
>>> 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(SecurityContextHolderAwareRequestFilter.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(AbstractAuthenticationProcessingFilter.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.java: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:152)
>>>
>>> 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>root cause</b> <pre>*com.ctc.wstx.exc.WstxUnexpectedCharException:
>>> Unexpected character '1' (code 49) in prolog; expected '<'*
>>> * at [row,col {unknown-source}]: [1,46]*
>>>
>>> com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)
>>>
>>> com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2032)
>>>
>>> com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1117)
>>>
>>> com.fasterxml.jackson.dataformat.xml.XmlFactory._initializeXmlReader(XmlFactory.java:439)
>>>
>>> com.fasterxml.jackson.dataformat.xml.XmlFactory._createJsonParser(XmlFactory.java:358)
>>>
>>> com.fasterxml.jackson.dataformat.xml.XmlFactory._createJsonParser(XmlFactory.java:27)
>>>
>>> com.fasterxml.jackson.core.JsonFactory.createJsonParser(JsonFactory.java:558)
>>>
>>> com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1856)
>>>
>>> org.hisp.dhis.dxf2.utils.JacksonUtils.fromXml(JacksonUtils.java:202)
>>>
>>> org.hisp.dhis.api.controller.MetaDataController.importXml(MetaDataController.java:228)
>>>
>>> org.hisp.dhis.api.controller.MetaDataController$$FastClassByCGLIB$$6089c6af.invoke(<generated>)
>>>
>>> org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
>>>
>>> org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
>>>
>>> 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:631)
>>>
>>> org.hisp.dhis.api.controller.MetaDataController$$EnhancerByCGLIB$$c31baab2.importXml(<generated>)
>>> 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(ServletInvocableHandlerMethod.java:104)
>>>
>>> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
>>>
>>> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.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)
>>>
>>> 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:84)
>>>
>>> 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(SecurityContextHolderAwareRequestFilter.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(AbstractAuthenticationProcessingFilter.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.java: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:152)
>>>
>>> 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.42 logs.</u></p><HR size="1"
>>> noshade="noshade"><h3>Apache Tomcat/7.0.42</h3></body></html>
>>>
>>> -------------------------------------------------------------------------------------------------------------
>>>
>>> rgds
>>> David
>>>
>>>
>>> 2014-06-12 8:27 GMT+03:00 Prosper BT <ptb3000@xxxxxxxxx>:
>>>
>>>> Hi Team,
>>>>
>>>> I have designed a multiple stage program with registration but seems I
>>>> can only export and import data elements only not attributes and the
>>>> program itself.
>>>>
>>>> Is this right or am missing something.
>>>>
>>>> Regards
>>>>
>>>> --
>>>> Prosper Behumbiize, MPH
>>>> Phone: +256 414 320076
>>>> Cell: +256 772 139037
>>>> +256 752 751776
>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>>>
>>
>> _______________________________________________
>> 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
>>
>>
>
References