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

Contact already exists #545

Open
0x66656c6978 opened this issue Sep 17, 2024 · 0 comments
Open

Contact already exists #545

0x66656c6978 opened this issue Sep 17, 2024 · 0 comments

Comments

@0x66656c6978
Copy link

The following code should never fail because a contact already exists in the second call, should it?

      const existingContactRecord = await hubspotClient.crm.contacts.searchApi.doSearch({
        properties: ['email'],
        filterGroups: [
          {
            filters: [
              {
                propertyName: 'email',
                operator: FilterOperatorEnum.Eq,
                value: fixEmail(organisation.email)
              }
            ]
          }
        ],
        sorts: ['-createdate'],
        limit: 1,
        after: '0'
      });
      if (existingContactRecord.total === 0) {
        logger.info(`Contact does not exist in HubSpot.`);
        const contactRecord = await hubspotClient.crm.contacts.basicApi.create({
          properties: {
            email: fixEmail(organisation.email)
          },
          associations: []
        });
      }

We're getting the following error

{"status":"error","message":"Contact already exists. Existing ID: 37765128953","correlationId":"2dea5219-07f2-40ce-82ec-9c2e302317a4","category":"CONFLICT"}
Headers: {"access-control-allow-credentials":"false","cf-cache-status":"DYNAMIC","cf-ray":"8c4a13c91f8f9bb0-FRA","connection":"keep-alive","content-length":"156","content-type":"application/json;charset=utf-8","date":"Tue, 17 Sep 2024 15:19:55 GMT","nel":"{\"success_fraction\":0.01,\"report_to\":\"cf-nel\",\"max_age\":604800}","report-to":"{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v4?s=S9Ok77QL9DhvfACAUyzwRTgLhuFcyx5NlfkD%2FpWoutbTP8gi4Kuwl%2BCg24gtdZxkt3BIOP5UOkBvqAPRc3uXl9JAjNbjZK52U53wmb6yhOFss48mZgr7xDjtQZM6MGrBykieRAlc3xfng%2BMR\"}],\"group\":\"cf-nel\",\"max_age\":604800}","server":"cloudflare","strict-transport-security":"max-age=31536000; includeSubDomains; preload","vary":"origin, Accept-Encoding","x-content-type-options":"nosniff","x-envoy-upstream-service-time":"32","x-evy-trace-listener":"listener_https","x-evy-trace-route-configuration":"listener_https/all","x-evy-trace-route-service-name":"envoyset-translator","x-evy-trace-served-by-pod":"fra04/hubapi-td/envoy-proxy-576d445cf9-fz2xj","x-evy-trace-virtual-host":"all","x-hubspot-correlation-id":"2dea5219-07f2-40ce-82ec-9c2e302317a4","x-hubspot-ratelimit-daily":"1000000","x-hubspot-ratelimit-daily-remaining":"999513","x-hubspot-ratelimit-interval-milliseconds":"10000","x-hubspot-ratelimit-max":"190","x-hubspot-ratelimit-remaining":"156","x-hubspot-ratelimit-secondly":"19","x-hubspot-ratelimit-secondly-remaining":"15","x-request-id":"2dea5219-07f2-40ce-82ec-9c2e302317a4"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant