Creating an CRM Item Contact with home phone and mobile in Java?
When trying to create a Contact Item (using the CRM Contact app), the following code
// works
fieldValues.add(new FieldValuesUpdate(getField(fields, "Address"), "value", contact.getPostalAddress()));
// will cause an exception to be thrown
fieldValues.add(new FieldValuesUpdate(getField(fields, "Phone"), "value", contact.getPhoneNumber()));
ItemCreate create = new ItemCreate(""+contact.getId(), fieldValues, Collections.<Integer>emptyList(), tags);
int itemId = apiFactory.getAPI(ItemAPI.class).addItem(PODIO_contact_appId, create, true);
The exception stack :
Exception in thread "main" APIException [status=Bad Request, error=invalid_value, description=Invalid value null (null): must be one of {'work_fax', 'mobile', 'work', 'private_fax', 'other', 'home', 'main'}, parameters=null]
at com.podio.ExceptionFilter.handle(ExceptionFilter.java:31)
at com.podio.RateLimitFilter.handle(RateLimitFilter.java:14)
at com.sun.jersey.api.client.Client.handle(Client.java:652)
at com.podio.LoginFilter.handle(LoginFilter.java:28)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:560)
at com.podio.item.ItemAPI.addItem(ItemAPI.java:47)
at com.namsor.geodem.crm.PODIOConnector.createContact(PODIOConnector.java:70)
at com.namsor.geodem.crm.PODIOConnector.main(PODIOConnector.java:62)
Anyone knows how to add a Phone field with home phone = 01xxx and mobile = 06xxx ? I guess the Map<String,Object> should be used but couldn't figure out how.
Best,
EC
-
[via mhrdev on Github]
Phone field requires a "type" as well. Try something like this:
Map<String, String> phoneValue = new HashMap<String, String>();
phoneValue.put("type", "main"); // 'workfax', 'mobile', 'work', 'private_fax', 'other', 'home', 'main'
phoneValue.put("value", contact.getPhoneNumber());
fieldValues.add(getField(fields, "Phone"), phoneValue)
Please sign in to leave a comment.
Comments
1 comment