← Back to team overview

dhis2-devs team mailing list archive

Re: error using curl command

 

Hi Channara,

You must properly encode your Khmer characters. Maybe Morten can say more
about this, but I am pretty sure it has something to do with this.

Here is the actual text (not screenshot), which indicates an error related
to some invalid characters.

Regards,
Jason


jason@jason-Precision-M2800:~/Downloads$ curl -d @1.json "
https://apps.dhis2.org/demo/api/trackedEntityInstances"; -X POST -H
"Content-Type: application/json" -u admin:district
<html><head><title>Apache Tomcat/7.0.63 - 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 - Unexpected character ('' (code 65279 /
0xfeff)): expected a valid value (number, String, array, object, 'true',
'false' or 'null')</h1><HR size="1" noshade="noshade"><p><b>type</b>
Exception report</p><p><b>message</b> <u>Unexpected character ('' (code
65279 / 0xfeff)): expected a valid value (number, String, array, object,
'true', 'false' or 'null')</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.core.JsonParseException: Unexpected character
('' (code 65279 / 0xfeff)): expected a valid value (number, String, array,
object, 'true', 'false' or 'null')
 at [Source:
{&quot;trackedEntity&quot;:&quot;PtPf474EHLM&quot;,&quot;orgUnit&quot;:&quot;NcA7HpabeAG&quot;,&quot;attributes&quot;:[{&quot;attribute&quot;:&quot;jZbsh2zpVWa&quot;,&quot;value&quot;:&quot;0201&quot;},{&quot;attribute&quot;:&quot;j9sScvXsXVO&quot;,&quot;value&quot;:&quot;Name
of
Person&quot;},{&quot;attribute&quot;:&quot;szmBW8EDWLx&quot;,&quot;value&quot;:&quot;Male&quot;},{&quot;attribute&quot;:&quot;adZnoplDPyx&quot;,&quot;value&quot;:&quot;48&quot;},{&quot;attribute&quot;:&quot;j16LxVcr8hV&quot;,&quot;value&quot;:&quot;1967-08-31&quot;},{&quot;attribute&quot;:&quot;T82mY6tjGVY&quot;,&quot;value&quot;:&quot;Married&quot;},{&quot;attribute&quot;:&quot;pyX2F5mjX5L&quot;,&quot;value&quot;:&quot;Siem
Reap&quot;},{&quot;attribute&quot;:&quot;CakCGhhkSJK&quot;,&quot;value&quot;:&quot;Siem
Reap&quot;},{&quot;attribute&quot;:&quot;zAKBPz96mci&quot;,&quot;value&quot;:&quot;Siem
Reap&quot;},{&quot;attribute&quot;:&quot;VstyNjHv8KM&quot;,&quot;value&quot;:&quot;គោកចក&quot;},{&quot;attribute&quot;:&quot;SmHt9k5t501&quot;,&quot;value&quot;:&quot;គោកចក&quot;},{&quot;attribute&quot;:&quot;CQqQwvsiZsg&quot;,&quot;value&quot;:&quot;ភូមិ
ត្រពាំងសេះ&quot;},{&quot;attribute&quot;:&quot;HVcRcWAW55I&quot;,&quot;value&quot;:&quot;ART&quot;},{&quot;attribute&quot;:&quot;RtAymQ0PT5p&quot;,&quot;value&quot;:&quot;410&quot;},{&quot;attribute&quot;:&quot;ZSEdw9AHbIC&quot;,&quot;value&quot;:&quot;1641&quot;},{&quot;attribute&quot;:&quot;JQtRizheDhD&quot;,&quot;value&quot;:&quot;2005-04-11&quot;},]};
line: 1, column: 2]
com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1487)
com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:518)
com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:447)
com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1461)
com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:683)
com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3602)
com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3547)
com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2578)
org.hisp.dhis.dxf2.events.trackedentity.JacksonTrackedEntityInstanceService.fromJson(JacksonTrackedEntityInstanceService.java:83)
org.hisp.dhis.dxf2.events.trackedentity.JacksonTrackedEntityInstanceService.addTrackedEntityInstanceJson(JacksonTrackedEntityInstanceService.java:133)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
com.sun.proxy.$Proxy177.addTrackedEntityInstanceJson(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
com.sun.proxy.$Proxy127.addTrackedEntityInstanceJson(Unknown Source)
org.hisp.dhis.webapi.controller.event.TrackedEntityInstanceController.postTrackedEntityInstanceJson(TrackedEntityInstanceController.java:357)
org.hisp.dhis.webapi.controller.event.TrackedEntityInstanceController$$FastClassBySpringCGLIB$$cfbc2606.invoke(&lt;generated&gt;)
org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:64)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
org.hisp.dhis.webapi.controller.event.TrackedEntityInstanceController$$EnhancerBySpringCGLIB$$ab43fc35.postTrackedEntityInstanceJson(&lt;generated&gt;)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
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:154)
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.hisp.dhis.security.filter.CorsFilter.doFilter(CorsFilter.java:93)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
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.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:140)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.hisp.dhis.security.filter.AutomaticAccessFilter.doFilter(AutomaticAccessFilter.java:115)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:57)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
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:344)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:82)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:151)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
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.63 logs.</u></p><HR size="1"
noshade="noshade"><h3>Apache
Tomcat/7.0.63</h3></body></html>jason@jason-Precision-M2800:~/Downloads$


On Mon, Sep 7, 2015 at 12:24 PM, channara rin <rin.channara@xxxxxxxxx>
wrote:

> hi morten,
> if i coding with PHP use CURL command. i still get the following error.
> and my json in attached file.
> By the way, i use apache v8 and DHIS2 v2.20
> [image: Inline image 1]
>
>
> On Fri, Sep 4, 2015 at 3:58 PM, channara rin <rin.channara@xxxxxxxxx>
> wrote:
>
>> If i tried use test with -u ... that is work fine. but if i add more
>> function like -X POST -d -v.... it doesn't work....
>>
>> On Fri, Sep 4, 2015 at 3:55 PM, Bob Jolliffe <bobjolliffe@xxxxxxxxx>
>> wrote:
>>
>>> Hi Channara
>>>
>>> I just had a look at your original mail and I see that the user admin
>>> was recognized so it means the curl option was ok but some issue with the
>>> password.  My guess is that you have some strange characters in the
>>> password which are being expanded/interpreted by the shell.
>>>
>>> Try quoting like:
>>> -u "admin:xxxxx"
>>> or
>>> -u 'admin:xxxxx'
>>>
>>>
>>> On 4 September 2015 at 09:46, channara rin <rin.channara@xxxxxxxxx>
>>> wrote:
>>>
>>>> Hi Morten,
>>>> Hi tried test with user:password first. but still error.
>>>>
>>>> On Thu, Sep 3, 2015 at 11:43 PM, channara rin <rin.channara@xxxxxxxxx>
>>>> wrote:
>>>>
>>>>> yes, it work too.
>>>>>
>>>>>
>>>>> On Thu, Sep 3, 2015 at 6:45 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx
>>>>> > wrote:
>>>>>
>>>>>> Try to test with something simpler
>>>>>>
>>>>>> curl -u user:pass http://server/api/dataElements
>>>>>>
>>>>>> And see if it works
>>>>>>
>>>>>> --
>>>>>> Morten
>>>>>>
>>>>>> On Thu, Sep 3, 2015 at 5:23 PM, Knut Staring <knutst@xxxxxxxxx>
>>>>>> wrote:
>>>>>>
>>>>>>> Channara, are you using GOW?
>>>>>>>
>>>>>>> https://github.com/bmatzelle/gow
>>>>>>>
>>>>>>> On Thu, Sep 3, 2015 at 12:08 PM, Morten Olav Hansen <
>>>>>>> mortenoh@xxxxxxxxx> wrote:
>>>>>>>
>>>>>>>> I have also seen weird issues on window versions of cURL where -u
>>>>>>>> user:pass is required to be FIRST (mac/linux should be fine)
>>>>>>>>
>>>>>>>> --
>>>>>>>> Morten
>>>>>>>>
>>>>>>>> On Thu, Sep 3, 2015 at 5:07 PM, Bob Jolliffe <bobjolliffe@xxxxxxxxx
>>>>>>>> > wrote:
>>>>>>>>
>>>>>>>>> Hi Channara
>>>>>>>>>
>>>>>>>>> The man page for curl indicates that the format of the command is:
>>>>>>>>>
>>>>>>>>> curl <options> <url>
>>>>>>>>>
>>>>>>>>> Try moving your url to the end of the line, after the options.
>>>>>>>>> Also you might want to add "http://localhost...";
>>>>>>>>>
>>>>>>>>> On 3 September 2015 at 11:01, channara rin <rin.channara@xxxxxxxxx
>>>>>>>>> > wrote:
>>>>>>>>>
>>>>>>>>>> Hi DHIS2 friends,
>>>>>>>>>> i tried use curl command to import tracker, but i got error.
>>>>>>>>>> can you help me what is problem?
>>>>>>>>>> ***THIS IS COMMAND RUNNING:
>>>>>>>>>> [image: Inline image 1]
>>>>>>>>>>
>>>>>>>>>> ***THIS IS CONSOLE in APACHE
>>>>>>>>>> [image: Inline image 2]
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> 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
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Knut Staring
>>>>>>> Dept. of Informatics, University of Oslo
>>>>>>> Norway: +4791880522
>>>>>>> Skype: knutstar
>>>>>>> http://dhis2.org
>>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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
>
>


-- 
Jason P. Pickering
email: jason.p.pickering@xxxxxxxxx
tel:+46764147049

PNG image

PNG image

PNG image


Follow ups

References