Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

415 Unsupported Media Type in API to setup pilot profile for a registered user (/api/pilot) #4

Open
lenikhilsingh opened this issue Aug 30, 2019 · 0 comments

Comments

@lenikhilsingh
Copy link

lenikhilsingh commented Aug 30, 2019

The data format for API : /api/pilot, as suggested in this docs seems wrong, Because i get the error: 415 Unsupported Media Type error.

Also, i looked up the code for addPilot here:

	@RequestMapping(method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> addPilot(
@RequestParam(value = "trainingCertificateDocument", required = false) MultipartFile trainingCertificateDocument,
@RequestParam(value = "pilotPayload") String pilotPayload
) {
try {

Pilot pilot = objectMapper.readValue(pilotPayload, Pilot.class);

validator.validate(pilot);

pilot.setTrainingCertificate(trainingCertificateDocument);
pilot.setTrainingCertificateDocName(resolveFileName(trainingCertificateDocument));

UserPrincipal userPrincipal = UserPrincipal.securityContext();

pilot.setResourceOwnerId(userPrincipal.getId());
pilot.setName(userPrincipal.getUsername());
pilot.setEmail(userPrincipal.getEmail());
Pilot savedPilotInstance = pilotService.createNewPilot(pilot);
return new ResponseEntity<>(savedPilotInstance, HttpStatus.CREATED);
} catch (PilotProfileAlreadyExist e) {
return new ResponseEntity<>(new Errors(e.getMessage()), HttpStatus.CONFLICT);

} catch (IOException e) {
return new ResponseEntity<>(new Errors("Bad Request"), HttpStatus.BAD_REQUEST);
}
}

And, as you can see, this API expects two values trainingCertificateDocument and pilotPayload both of which are not present in the example data format for this particular API.

Kindly, comment if i am missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant