0

I hosted a Springboot app on Heroku. Build and deploy works perfectly fine. However, I see this error whenever I want to access the method. There was an unexpected error (type=Bad Request, status=400).It works perfectly fine on Postman if I use loclhost but throws error using the Heroku's app.

Here is what the controller looks like. I am guessing this is where the issue is coming from.

.

..
@Slf4j
@RestController
@RequestMapping("/api/v1/")
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping(value = "/addUser")
    public ResponseEntity<AddResponseDTO> addUser(@RequestBody AddUserDTO addUserDTO) throws ApplicationException {
        AddResponseDTO response = userService.saveUser(addUserDTO);
        return ResponseEntity.ok(response);
    }

}

What do you think I can I do make the api work on Heroku?

ojo
  • 71
  • 1
  • 9

2 Answers2

0

Apparently I was trying to access a POST REQUEST it will definitely throw such error. But the mistake here was that, I was trying to work with a local database.Thus, I created a shared cluster using Mongo Atlas, updated the configuration in my application.properties, I added the variable config to Heroku and everything works just fine now.

ojo
  • 71
  • 1
  • 9
-1

The issue not with the Springboot controller. check your Heroku configurations like below.

=== <app_name>
Git Url:       git@heroku.com:<app_name>.git
Web Url:       https://<app_name>.herokuapp.com/
S. Anushan
  • 728
  • 1
  • 6
  • 12