hubspot-net / HubSpot.NET

C# .NET Wrapper around the common HubSpot APIs.
MIT License
112 stars 137 forks source link

No Associations on Deals #84

Closed LeeStevens318 closed 1 year ago

LeeStevens318 commented 4 years ago

Describe the bug When pulling a list of Deals and settings the "includeAssociations" as true it's not populating the associations.

DealApiNoAssociations

When querying the API directly the information is retrieved:

DealApiNoAssociationsDirect

URL:

https://api.hubapi.com/deals/v1/deal/paged?hapikey=KEY_HERE&offset=100&includeAssociations=true&limit=2&properties=job_no

Repro Steps

var deals = new List<Deal>();

try
{
    var moreResults = true;
    long offset = 0;

    while (moreResults)
    {
        var allDeals = api.Deal.List<Deal>(true,
            new ListRequestOptions
            {
                PropertiesToInclude = new List<string>
                {
                    "dealname",
                    "amount",
                    "job_no",
                    "dealtype",
                    "dealstage",
                    "createdate",
                    "pipeline",
                    "hubspot_owner_id"
                },
                Limit = 100,
                Offset = offset
            });

        deals.AddRange(allDeals.Deals);

        moreResults = allDeals.MoreResultsAvailable;
        if (moreResults)
            offset = allDeals.ContinuationOffset;
    }
}
catch (Exception e)
{
    Console.WriteLine(e);
    throw;
}

AND Deal Class

public class Deal : DealHubSpotModel
{
    /// <summary>
    /// 
    /// </summary>
    [DataMember(Name = "job_no")]
    public int JobNumber { get; set; }

    /// <summary>
    /// 
    /// </summary>
    [DataMember(Name = "createdate")]
    public long CreateDate { get; set; }
}

Expected behavior Associations shouldn't be null

aronsimpletix commented 2 years ago

I'm running into an issue where I can create: Contacts, companies, deals. But I cannot create DealHubSpotAssociation

LeeStevens318 commented 2 years ago

@aronsimpletix you should be able to map associations during creation:

// Removed invalid code - see response below.
aronsimpletix commented 2 years ago

Hi Lee

Associations was not in the properties. Did you add it to your code?

On Tue, Feb 22, 2022 at 4:10 PM LeeStevens318 @.***> wrote:

@aronsimpletix https://github.com/aronsimpletix you should be able to map associations during creation:

// Map Deal to HubSpot Model var hubSpotDeal = new DealDto { Id = deal.Id, Name = deal.Name, Stage = deal.Stage, Pipeline = deal.Pipeline, OwnerId = deal.OwnerId, CloseDate = deal.CloseDate, Amount = deal.Amount, DealType = deal.DealType, JobNumber = deal.JobNumber.ToString(), Location = deal.Location, Vertical = deal.Vertical, CreatedBySync = deal.CreatedBySync, CreateDate = deal.CreateDate.ToString(), Associations = { AssociatedCompany = new [] { deal.CompanyId } } };

— Reply to this email directly, view it on GitHub https://github.com/hubspot-net/HubSpot.NET/issues/84#issuecomment-1048214656, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPJPMQ4Z73MAJ55BFJS6H3U4P3UVANCNFSM4O33JAJA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

LeeStevens318 commented 2 years ago

Hi @aronsimpletix, yeah sorry i was just editing my response. I realised this was on the old package i used i switched to: https://github.com/skarpdev/dotnetcore-hubspot-client

aronsimpletix commented 2 years ago

That’s weird, the old package is better than the new one?

On Tue, Feb 22, 2022 at 4:13 PM LeeStevens318 @.***> wrote:

Hi @aronsimpletix https://github.com/aronsimpletix, yeah sorry i was just editing my response. I realised this was on the old package i used i switched to: https://github.com/skarpdev/dotnetcore-hubspot-client

— Reply to this email directly, view it on GitHub https://github.com/hubspot-net/HubSpot.NET/issues/84#issuecomment-1048217011, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPJPMXRW3QNOE2TN5PS5RLU4P4ARANCNFSM4O33JAJA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>