在邮递员中张贴时出现404错误 [英] 404 error when post in Postman

查看:98
本文介绍了在邮递员中张贴时出现404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试发送POST请求,该请求是 Person 对象,其中包含联系人列表。
但是我不知道这是否是发送列表的正确语法:

I´m trying to send a POST request that is an Person object that contains a list of contacts. But I don´t know if this is the correct syntax to send a list:

 {
    "name":"romulo",
    "contacts" :  [ 
        { 
            "contact" : "3466577" 

        },
            { 
            "contact" : "532423" 

            }
        ]
    }

但是让我返回404错误

But keeps me returning a 404 error

我在做什么错了?

发布方法:

@PostMapping("/person")
public void addPerson(@Valid @RequestBody Person person) {
    Person savedPerson = personRepository.save(person);
    List<Contact> contacts = person.getContacts();
    for (Contact contact1 : contacts) {
        contactRepository.save(contact1);
    }

}


推荐答案

当服务器无法找到与您的确切请求匹配的方法时,将返回HTTP 404。

HTTP 404 is returned when the server is unable to find method to match your exact request.

对于上述请求,URL为 http://< context> / requestpath ,请求方法为POST。( http:// localhost:8080 / person

For the mentioned request have the url as http://<context>/requestpath with request method as POST.(http://localhost:8080/person)

检查请求正文,所有字段应与Person对象完全匹配,否则可能会返回HTPP 400。

Check the request body and all the fields should exactly match the Person object else it may return HTPP 400.

这篇关于在邮递员中张贴时出现404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆