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.