"Трассие": "org.springframework.http.converter.httpmessAgexexpectable: publicexable: publicexexpectable: publicexable ispectipable: publicexable ispectipable: iRempable: IRepeCeptable. org.springframework.http.responseentity
Это скрипт:
Код: Выделить всё
let data = [{
"name": "Alex M",
"email": "[email protected]",
"password": "ASF2354SDF"
},
{
"name": "Lucas M",
"email": "[email protected]",
"password": "FGSASD123"
},
{
"name": "Jenifer L",
"email": "[email protected]",
"password": "531234asd"
}
];
data.forEach(item => {
pm.sendRequest({
url: "http://localhost:8080/library/users",
method: "POST",
header: { "Content-Type": "application/json" },
body: {
mode: "raw",
raw: JSON.stringify(item)
}
}, (err, res) => {
if (err) {
console.error("Error:", err);
} else {
console.log("Response:", res.json());
}
});
});
< /code>
Это метод сообщения: < /p>
@PostMapping
public ResponseEntity create(@RequestBody User user) {
return ResponseEntity.status(HttpStatus.CREATED).body(userService.saveUser(user));
}
< /code>
Класс пользователя: < /p>
@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
@Column(nullable = false, unique = true)
private String email;
private String password;
}
[*] Я добавил ключ типа контента и его значение (приложение/json) в заголовках на почтальце, и он продолжает показывать один и тот же статус. /> < /li>
изменил тело на < /p>
Код: Выделить всё
body: JSON.stringify(item)
Подробнее здесь: https://stackoverflow.com/questions/795 ... equest-scr