Property cannot be missing or null error on createOrUpdate contact api

I am using a java server to make this request. And I’ve checked the property values I’m submitting against postman which works just fine. For some reason it fails with my java code. The following is the code I have.

ErrorResponse hubspotResponse = hubspotClient.createOrUpdateContact(emailAddress, contactUpdateRequest);

public ErrorResponse createOrUpdateContact(String email, ContactUpdateRequest request) throws Exception {
 URIBuilder url = this.newUrlBuilder("/contacts/v1/contact/createOrUpdate/email/" + email);
 Response<ErrorResponse> response = this.delegateClient.doPost(url.toString(), ContactUpdateRequest, ErrorResponse.class);
}
public class ContactUpdateRequest {
 String vid;
 String email;
 List<Property> properties;

 public ContactUpdateRequest() {
 }

 public String getVid() {
 return this.vid;
 }

 public void setVid(String vid) {
 this.vid = vid;
 }

 public String getEmail() {
 return this.email;
 }

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

 public List<Property> getProperties() {
 return this.properties;
 }

 public ContactUpdateRequest setProperty(String name, String value) {
 if (this.properties == null) {
 this.properties = new ArrayList();
 }

 this.properties.add(new Property(name, value));
 return this;
 }

 public ContactUpdateRequest setProperties(List<Property> properties) {
 this.properties = properties;
 return this;
 }
}
public class Property {
 String property;
 Object value;

 public Property(String name, Object value) {
 this.property = name;
 this.value = value;
 }

 public String getName() {
 return this.property;
 }

 public Object getValue() {
 return this.value;
 }

 public boolean equals(Object o) {
 if (this == o) {
 return true;
 } else if (!(o instanceof Property)) {
 return false;
 } else {
 Property property = (Property)o;
 return Objects.equal(property, property.property) && Objects.equal(this.value, property.value);
 }
 }

 public int hashCode() {
 return Objects.hashCode(new Object[]{this.property, this.value});
 }
}

On the doPost line I always get a 400 error that says “property cannot be missing or null.” I don’t see why this is happening, if anyone can please help.

Hi, @KMartinez82 :waving_hand: Let’s see if we can get this conversation started for you. Hey, @lbkulinski @mclayton, do you have any Java wisdom you can share with @KMartinez82?

Thank you very much! — Jaycee

I was able to figure it out, had to do with how serialization works in that it uses getter method name instead of the property itself. So even though the Property class had a property and a value, because getProperty was labeled as getName, it would get converted to json with {name: name, value: value} instead of {property: name, value: value}