400 Bad Request

498 views Asked by At

I am getting 400 Bad Request when trying this :

 List<Object> list = new ArrayList<Object>();
 Object[]  mongodata = restTemplate.getForObject(mongourl,Object[].class,fileName);
                 list = Arrays.asList(mongodata);
System.out.println("\n MONGODATA \n"+list);

where mongourl is the url for calling mongodb, filename is "EC001.TXT". The data that will be returned is :

[
    {
        "_id": {
            "$oid": "5e141d337d7558rd1f2e91c8"
        },
        "data": [
            {
                "payload": [
                    {
                        "DATA001": "ECE,100,MATH,99,PHY,90",
                        "DATA002": 1
                    }
                ]
            },
            {
                "payload2": [
                    {
                        "SFTPHOST": "test.host",
                        "SFTPPASSWORD": "test.password",
                        "SFTPUSERNAME": "test.username",
                        "FILETYPE": "TEST",
                        "FILENAME": "EC001.TXT",
                        "SFTPPATH": "TEST.path"
                    }
                ]
            }
        ],
        "_etag": {
            "$oid": "5e141d33d6018000083f312b"
        }
    }
]
1

There are 1 answers

0
Thira On

It was something wrong with the url. In postman, we need not give the variables in the url as a string but we need to do it in Java. That was what threw this error. Made the variables a string separately and then added it to the url and it worked.