C# Hubspot Contacts class already built?

Highlighted
New Member

Has anyone already built a C# Contacts class to deserialize the api returned json into?

Thanks!

Reply
0 Upvotes
5 Replies 5
Highlighted
HubSpot Employee

@cbarnes199 Hey there is a popular class built out that you can read up on and leverage to do this. It is called Json.NET. Here is a link to the documentation on it. Let me know if this helps or not.
http://www.newtonsoft.com/json

Reply
0 Upvotes
Highlighted
New Member

@pmanca Yes Json.NET is a very good tool but are the .NET object classes for the HubSpot items (ie Contacts) already built somewhere so that we can use Json.NET to serialize/deserialize directly to strongly typed objects - without having to create the required object classes ourselves?
Thanks for your help!

Reply
0 Upvotes
Highlighted
New Member

I found this pretty helpful. I could not use the results directly buy they saved a lot of typing.

http://json2csharp.com/

This will generate C# classes off the json and then you just have to do some tweaking out of the names with - in them that are not allowed.

Reply
0 Upvotes
Highlighted
New Member

@cbarnes199 Thanks! That sounds good and will definitely check it out.

Reply
0 Upvotes
Highlighted
New Member

Below is the hubspot api response in c# format obtained from json2csharp

public class HubSpotResponse
{
    public string status { get; set; }
    public string message { get; set; }
    public string correlationId { get; set; }
    public List<string> invalidEmails { get; set; }
    public List<FailureMessage> failureMessages { get; set; }
    public string requestId { get; set; }

    public class FailureMessage
    {
        public int index { get; set; }
        public Error error { get; set; }
    }
    public class Error
    {
        public string status { get; set; }
        public string message { get; set; }
    }

}
Reply
0 Upvotes