Create Deal in C#


#1

Does anyone have an example on how to create a Deal in HubSpot using C#, RestSharp library?


#4

Welcome, @wmamani.

What about something like this?

var client = new RestClient("https://api.hubapi.com/deals/v1/deal?hapikey=redacted");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\n  \"associations\": {\n    \"associatedCompanyIds\": [\n      263467842\n    ],\n    \"associatedVids\": [\n      100001\n    ]\n  },\n  \"properties\": [\n    {\n      \"name\": \"dealname\",\n      \"value\": \"C# Test Deal\"\n    },\n    {\n      \"name\": \"dealstage\",\n      \"value\": \"appointmentscheduled\"\n    },\n    {\n      \"name\": \"pipeline\",\n      \"value\": \"default\"\n    },\n    {\n      \"name\": \"closedate\",\n      \"value\": 1548349551000\n    },\n    {\n      \"name\": \"amount\",\n      \"value\": \"5000\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

I'm not familiar with C#, but I generated that through Postman's code snippets tool.


#5

Thanks @Isaac_Takushi