Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Company doesn't work #7

Closed
luposlip opened this issue Oct 23, 2014 · 7 comments
Closed

Create Company doesn't work #7

luposlip opened this issue Oct 23, 2014 · 7 comments
Labels

Comments

@luposlip
Copy link

I call the API using these lines:
Company company = new Company();
company.setName("Blue Sun");
company.setCompanyID("1");
company.setPlan(new Company.Plan("premium"));
company.addCustomAttribute(CustomAttribute.newIntegerAttribute("foddstuff-items", 246));
company.addCustomAttribute(CustomAttribute.newStringAttribute("bestseller", "fruity oaty bar"));
Company.create(company);

I get the company back with this:
HashMap<String, String> map = new HashMap<String, String>();
map.put("name", "Blue Sun");
Company company2 = Company.find(map);

And it seems fine. But no company is created in my intercom account.
And no exception is thrown.

Please advice?

@luposlip luposlip changed the title Create Company doesn Create Company doesn't work Oct 23, 2014
@dehora
Copy link
Contributor

dehora commented Oct 23, 2014

Hi @luposlip,I think you're seeing this because of a particular behavior in Intercom which is reflected in the API - when the company has no users the company doesn't appear in API data or the product. It's mentioned http://doc.intercom.io/api/#list-companies (Note that the API does not include companies who have no associated users in list responses.) but that's easy to miss. I'm hoping this will get addressed but it'll be a change in Intercom rather than a client library change.

If you see this with a company that has users (eg a company that's visible in the product), please let me know.

@luposlip
Copy link
Author

Alright @dehora . Just tried below code:

    HashMap<String, String> map = new HashMap<String, String>();
    map.put("name", "Blue Sun");
    Company company2 = Company.find(map);

    Map<String, String> params = new HashMap<String, String>();
    params.put("email", "[email protected]");
    User user = User.find(params);

    user.addCompany(company2);
    User.update(user);

Both company2 and user seems fine in the debugger, so data seem to be read correctly from the API.

But The last line of code - User.update(user) - throws the following:

Exception in thread "main" io.intercom.api.ClientException: bad 'updated_at' parameter
at io.intercom.api.HttpClient.throwException(HttpClient.java:198)
at io.intercom.api.HttpClient.handleError(HttpClient.java:154)
at io.intercom.api.HttpClient.runRequest(HttpClient.java:147)
at io.intercom.api.HttpClient.post(HttpClient.java:93)
at io.intercom.api.DataResource.update(DataResource.java:24)
at io.intercom.api.User.update(User.java:61)

@dehora
Copy link
Contributor

dehora commented Oct 23, 2014

@luposlip thanks! I can replicate what you're seeing, working on a fix.

@luposlip
Copy link
Author

Appreciate it @dehora! :-)

@dehora
Copy link
Contributor

dehora commented Oct 23, 2014

@luposlip There's a 0.0.3 version in jcenter now if you want to try it out.

@dehora dehora added the bug label Oct 23, 2014
@luposlip
Copy link
Author

It works now, thanks for the speedy response! :)

@bledari
Copy link

bledari commented Jul 28, 2020

Hi I have some issues.
I was trying to create companies through Postman and it didn't work, then with curl code it worked! I can retrieve companies by id and understand the list of companies displays only those with user. Now users I see are contacts. I was able to associate a contact to a company (difficult because doc has error, mark it as a POST) but still nothing in list companies.

You can try to reproduce this or just pass me some working Postman collection and I figure out why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants