-1

I want a user to receive the invitation to an organization through his email, the problem is that the error 422, but I don't know what I have to modify in my object so that the Github Api can process the information.


    @PostMapping("/add")
    public Members postMembers() {

        return webClientBuilder.build()
                .post()
                .uri(ADD_MEMBERS)
                .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
                .header("Authorization", "Bearer " + TOKEN)
                .retrieve()
                .bodyToMono(Members.class)
                .block();


    }

POJO

public class Members {

    private String org = "Escihu-Wizards";
    private String email;
    private String role = "direct_member";

    public String getOrg() {
        return org;
    }

    public void setOrg(String org) {
        this.org = org;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }
}
Artyom47
  • 7
  • 4
  • Does this answer your question? [Unexpected error response from GitHub API 422 when attempting to create issue](https://stackoverflow.com/questions/54008483/unexpected-error-response-from-github-api-422-when-attempting-to-create-issue) – Martin Zeitler Oct 12 '22 at 02:08
  • not sure what API are you using but typically POST requests require some body and in your case request body will be empty. – Alex Oct 12 '22 at 04:42
  • @Alex You were right in my request, the body of the json is missing. – Artyom47 Oct 12 '22 at 05:13

1 Answers1

0

Send valid model data in your HTTP request body. Check the body of the 422 response to learn why the data provided in the request is not valid.

Janil101
  • 306
  • 6