APIs & Integrations

tbalthazard
Miembro

Api - Problem to set property hs_email_headers on incoming Email Object

Hi,

 

I try to create an incoming email with api call.

POST https://api.hubapi.com/crm/v3/objects/emails

Body :

 

 

{
    "properties": {
        "hubspot_owner_id": "63590768",
        "hs_email_text": "bodyContent",
        "hs_email_subject": "test hs_email_direction incoming 1",
        "hs_email_direction": "INCOMING_EMAIL",
        "hs_timestamp": 1681894200000,
        "hs_email_status": "SENT"
    },
    "hs_email_headers": {
        "from": {
            "email": "contact1@company1.com"
        },
        "to": [
            {
                "email": "contact2@company2.com"
            },
            {
                "email": "myself@mycompany.com"
            }
        ],
        "cc": [
            {
                "email": "contact3@company3.com"
            }
        ]
    }
}

 

 

Response is 201

 

But when looking on hubspot CRM UI

tbalthazard_0-1681918118452.png

hs_email_headers have been ignored.

 

For an outgoing email same payload with only difference on :

"hs_email_direction": "EMAIL"

The header part in hubspot CRM UI is right

 

Could you helpme on this one as I surely missing something?

 

Regards

Tibo

 

 

0 Me gusta
6 Respuestas 6
PamCotton
Administrador de la comunidad
Administrador de la comunidad

Api - Problem to set property hs_email_headers on incoming Email Object

I want to invite our top experts @Anton and @DanielSanchez do you have any recommendations?

 

Thank you,

Pam

Você sabia que a Comunidade está disponível em outros idiomas?
Participe de conversas regionais, alterando suas configurações de idioma !


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Me gusta
PamCotton
Administrador de la comunidad
Administrador de la comunidad

Api - Problem to set property hs_email_headers on incoming Email Object

Hey @AJoshi95, thank you for posting in our Community.

 

Could you please specify what you are currently experiencing?  Since this is not a new post, the more information, screenshots, and details you can provide, the better I can advise on the next steps.

 

Kindly,

Pam

Você sabia que a Comunidade está disponível em outros idiomas?
Participe de conversas regionais, alterando suas configurações de idioma !


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Me gusta
AJoshi95
Miembro

Api - Problem to set property hs_email_headers on incoming Email Object

Hey @PamCotton,

 

Thanks for your response.

 

I am using Ruby gem hubspot-api-client for my integration. (I am pretty new to Hubspot integration as well as Ruby and Ruby on Rails.)

 

Below is a code snippet where I am updating the Contact, Company and Email objects. The Contact, Company and Email objects get created successfully, all the associations also get created. The only issue is the Email headers not showing correctly.

    def save_to_crm 
        contact_association = []
        if company_name?
          company_body = {associations:[], properties:{"name":company_name, "domain": company_website}}
          company_api_response = crm_client.crm.companies.basic_api.create(body: company_body)
          if company_api_response.id
            contact_association = [{"types":[{"associationCategory": "HUBSPOT_DEFINED", "associationTypeId":1}], "to":{"id":company_api_response.id}}]
          end
        end
        contact_body = {associations:contact_association, properties:{"firstname": first_name, "lastname": last_name, "email": email_address, "company": company_name}}
        contact_api_response = crm_client.crm.contacts.basic_api.create(body: contact_body)
        if contact_api_response.id
          email_association = [{"types":[{"associationCategory": "HUBSPOT_DEFINED", "associationTypeId":198}], "to":{"id":contact_api_response.id}}]
          if company_api_response.id
            email_association[1] = {"types":[{"associationCategory": "HUBSPOT_DEFINED", "associationTypeId":186}], "to":{"id":company_api_response.id}}
          end
          email_header_hash = {"from":{"email":email_address, "firstName":first_name, "lastName":last_name}, "sender":{"email":email_address, "firstName":first_name,"lastName":last_name},"to":{"email":"info@mydomain.com", "firstName":"Info", "lastName":"MyDomain.com" }, "cc":[], "bcc":[]}
          email_body = {associations: email_association, properties:{"hs_email_direction": "INCOMING_EMAIL", "hs_email_subject": "Website Contact Us Page - Contact", "hs_email_text": message, "hs_timestamp": Time.now.utc.iso8601, "hs_email_headers": email_header_hash.to_json}}
          email_api_response = crm_client.crm.objects.emails.basic_api.create(body: email_body)
        end
    end

    def crm_client
        return Hubspot::Client.new(access_token: Rails.application.credentials.dig(:hubspot, :API_KEY))
    end

The form used to capture the data:

AJoshi95_1-1721137409735.png

Resulting Company record:

AJoshi95_2-1721137655505.png

 

Notice the data highlighted in yellow.

AJoshi95_3-1721137764447.png

 

Company, Contact and associations updated correctly but the email header details are blank.

AJoshi95_4-1721137814164.png

 

 

0 Me gusta
Jaycee_Lewis
Administrador de la comunidad
Administrador de la comunidad

Api - Problem to set property hs_email_headers on incoming Email Object

Hey, @tbalthazard. Thanks for flagging this. I'll take your example and to reproduce the issue on my end. 

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Me gusta
AJoshi95
Miembro

Api - Problem to set property hs_email_headers on incoming Email Object

Hi,

I am facing the exact same issue. Do you have an update on this issue?

0 Me gusta
tbalthazard
Miembro

Api - Problem to set property hs_email_headers on incoming Email Object

Hello, were you able to reproduce and correct the problem?

Regards

Tibo

0 Me gusta