unable to create patient via rest in open web app

Just created an open web app and I’m trying to register a patient via rest. I’m following https://wiki.openmrs.org/display/docs/Create+Patient. I have the following javascript code below to register create a patient

$('#patientRegForm').submit(function(event) {
      event.preventDefault();

      var person = {
        gender: $("input[name='gender']:checked").val(),
        names: [
          {givenName: $('#givenName').val()},
          {familyName: $('#familyName').val()}
        ],
        birthdate: $("#birthdate").val()
      }
      
      $.ajax({
        type: "POST",
        url: "/openmrs/ws/rest/v1/person",
        data: JSON.stringify(person),
        success: function(data) {
          console.log(data)
        },
        contentType: "application/json"
      })

When I submit my form all I get is a 400 error saying bad request in the browser console but there is no exception in the logs.

My server is 2.1.0-SNAPSHOT created with sdk

FYI, I wouldn’t recommend one to code against a snapshot version. Do you really have to ‘stringify’ the person object? Do you have logs from the server?

Unfortunately there is nothing in the logs. It’s just the browser console that even gives the 400 bad request

Can you share the expanded snapshot of that POST request in the js console?

Maybe this is the problem.

givenName and familyName should both be attributes of one object, but I think this is two different objects, one with only the given name, and one with only the family name.

@darius thank you very much for noticing that. That was indeed the problem. Did not read the wiki properly.

Thanks.