Forum Stats

  • 3,733,814 Users
  • 2,246,824 Discussions
  • 7,856,883 Comments

Discussions

Getting a Bad Request error while trying to call the same project using Rest API.

We have developed a Project ,which needs to be called to 2 times one by one. The issue is when it is being called the first time through WSO2(middleware) in a form of JSON request via REST API ,everything is working fine but when it is being called the second time with the same JSON request we are getting Bad Request error with the detail being " Error reading JSON request data: Illegal control code at 1".

Can anybody suggest what is happening wrong in the second call.

{

    "type": "HTTP://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",

    "title": "Bad Request",

    "detail": "Bad Request: Error reading JSON request data: Illegal control code at 1 [character 2 line 1]",

    "internal-code": ""

}

Answers

  • Richard Napier
    Richard Napier Member Posts: 208 Silver Badge
    edited January 12

    Hi Sourabh

    Just to be clear : are you saying that you call the same project two times, with the same input? Or do you mean that the output of the first call, is the input for the second call?

    If what you are getting is a 400 error for malformed request, then I would imagine that the second call either

    a) contains Invalid characters

    b) is using the wrong content type (text/html instead of application/json or something) resulting in the message not being formed correctly.

    Hope that helps

  • Sourabh Kshitiz
    Sourabh Kshitiz Member Posts: 43 Red Ribbon
    edited January 13

    Hi Richard,

    Wishing you a very Happy New Year and good times ahead.

    Actually I am calling the same project two times with just change in one attribute at the request level and the response of the first request is not related to the input attributes in the second request. The error seems to be the one as suggested by you as if it is working the first time then we can conclude that at least at the OPA level everything is correct.

    The same request when I am testing through Postman is working fine for me and we are getting expected results but when it is being called the second time through WSO2 it is generating the above mentioned error of Bad Request, while the first time it is working fine.

    I have suggested the same to the concerned teams that there must be some error which is happening while transformation. Will update once the issue gets resolved.

    Thanks

  • Richard Napier
    Richard Napier Member Posts: 208 Silver Badge

    Happy to help.

    It will be important to obtain clarity on this point, before investigating other potential issues as to whether the integration server is overloaded / erroring out in some other way (but I kind of would expect 500 class errors, not 400 class), or something similar with IA. I have no idea of the volume of calls you are putting into your IA so I cannot comment.

  • Sourabh Kshitiz
    Sourabh Kshitiz Member Posts: 43 Red Ribbon

    The Project is deployed on the dev server only and this is being done as a part of Integration Testing. That's why even the server is not overburdened . Likewise there one another project that I had developed and same thing is happening in that too that second call is not working fine.

    Most probably going by the error it should be some parsing error ,where the server is not receiving JSON request in the format it expects and that's why it is erroring out why syntactically.

  • Richard Napier
    Richard Napier Member Posts: 208 Silver Badge

    Cool. I was just checking. You know the expression "Hope for the best, plan for the worst" ;)

Sign In or Register to comment.