Read companies using idProperty returning 404

Hello,

I am trying to return a specific company based on it’s name, I have set idProperty on this to be ‘name’ and you can see the call I am making below:

https://api.hubapi.com/crm/v3/objects/companies/Melt%20Industries?archived=false&idProperty=name&hapikey=

I realise this needs to be a unique property but having done a similar thing with ‘Contacts’ I figure this should work too? Ideally I need to be able to pass the company name into this call and not the actual company ID.

Any help would be appreciated.

Thanks,

@RFrance

I would suggest employing the CRM Search endpoint

Hi @RFrance ,
You can search the company with using name via HubSpot api.
Node.JS code :
const request = require(“request”);
var options = { method: ‘POST’,
url: ‘https://api.hubapi.com/crm/v3/objects/companies/search’,
qs: { hapikey: ‘HubSpotAPIKey’ },
headers:
{
‘Content-Type’: ‘application/json’ },
body: {
“filterGroups”:[
{
“filters”:[
{
“propertyName”: “name”,
“operator”: “EQ”,
“value”: “Melt Industries”
}
]
}
]
},
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.

Thanks, using the search endpoint was successful.

Any reason why idProperty in this instance was not working? It works for ‘Contacts’ endpoints. Is this a potential bug with the read endpoint?

I am having this same issue, and also noticed that it seems to work with contacts. It returns a 404 with HTML content. If you specify a string and don’t set an id property you at least get Json with an “object not found” message. This makes me assume setting an id property along with a string is valid and it just isn’t finding anything despite the value being valid. I don’t know if there is anything with the uniqueness constraint and whether that needs to be enabled for the property, but I can guarantee the values will be unique on my side, and there is only a single company at this time for testing.

Another interesting thing is that idProperty can be set to an invalid property and it doesn’t validate it. Due to that, I can’t say for sure whether the property is actually being recognized as valid, although it is as I can get that custom property back in the object when retrieving it by the object ID.