#500 Internal Error Server

1 messages ยท Page 1 of 1 (latest)

marsh axle
#

even AI can't help me anymore. I'm developing an API with SpringBoot and im trying to send a post request through Postman. I've checked both Content-Type and Accept Headers, but the problem is still there. The changes affect the database, as if no problem was caught.

The controller class is just fine, I don't know what more could be the problem. If I'm lacking any details to understand the problem, please point it out.

ebon sphinxBOT
#

<@&987246584574140416> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
Even AI can't help me anymore. I'm developing an API with SpringBoot and im trying to send a post request through Postman. I've checked both Content-Type and Accept Headers, but the problem is still there. The changes affect the database, as if no problem

It seems like there might be an issue with your code or configuration in SpringBoot causing the internal server error. Make sure to check your logs for more specific error messages that can help you pinpoint the problem. Also, ensure that your Postman request body is correctly formatted according to what the API endpoint expects.

Useful links:

echo mural
#

you need to check the entire spring boot debug log, sometimes 500 Internal Server Error seems to happen out of nowhere, but in reality its cause is much earlier in the log

marsh axle
#

the log says that there is no converter for [class.java.util.LinkedHashMap] with preset Content-Type 'text/html;charset=UTF-8']

echo mural
#

can you send the full error, and relevant code?

marsh axle
#

one moment

#

controller:

@PostMapping("/save")
public Expense save(@RequestBody Expense expense){
return expenseService.save(expense);
}

model (not using lombok):

public Expense(String descr, BigDecimal value, LocalDate date, Long userId){
this.descr = descr;
this.value = value;
this.date = date;
this.userId = userId;
}

public Long getId() {
    return id;
}

public String getDescr() {
    return descr;
}

public BigDecimal getValue() {
    return value;
}

public LocalDate getDate() {
    return date;
}

public Long getUserId(){
    return userId;
}

public void setDescr(String descr) {
    this.descr = descr;
}

public void setValue(BigDecimal value) {
    this.value = value;
}

public void setDate(LocalDate date) {
    this.date = date;
}

public void setUserId(Long userId){
    this.userId = userId;
}

}

service:

public Expense save(Expense expense){
return expenseRepository.save(expense);
}

#

ill send the full error in just a minute

#

2025-10-23T15:25:39.939-03:00 WARN 82352 --- [financectrl] [nio-8080-exec-6] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class java.util.LinkedHashMap] with preset Content-Type 'text/html;charset=UTF-8']

echo mural
#

This could be a json issue, json objects are sometimes represented as linkedhashmaps. It might be worth it to try marking the constructor as @JsonCreator

#

If not, I am not surr

marsh axle
#

ok, I'll take a look at JsonCreator

#

but since I'll be using the API through the web, making html requests (url-encoded), probably I just shouldn't care about that, right?

#

maybe I am the one creating problems where they shouldn't be

echo mural
marsh axle
#

but that's the thing, it does work, I can see the changes in PgAdmin, the problem is that the API isn't returnig JSON to Postman

echo mural
#

Just try JsonCreator really quickly, in the end you might use json down the road anyway

marsh axle
#

hm, that's true

#

thank you for the attention ๐Ÿ™๐Ÿ™

echo mural
#

No problem, lmk if it worked

marsh axle
#

AI told me to force ResponseEntity on the controller method

echo mural
#

Try it. In my project I do something like ResponseEntity<Void> fo the return type, and return ResponseEntity.no_content(). build or something like that

marsh axle
#

it worked ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰

#

ty again bro

echo mural
#

Nw