- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
The request was aborted: The connection was closed unexpectedly.
Aug 12, 2020 6:35 AM
Hi,
I am doing a PUT request using Postman and it is successfully returning a Status Code 400 and a message, but when I run below C# code (which I copied from Postman), I get Status Code 0 and error message "The request was aborted: The connection was closed unexpectedly.". Please can someone advise what could be the issue?
Environment: Visual Studio 2015
.NET Framework: 4.6.1
Code:
var client = new RestClient("https://api.hubapi.com/companies/v2/companies/XXXXXXXX?hapikey=XXXXXXXXXXXXXXXXXXXXXXXXXX");
client.Timeout = -1;
var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\r\n \"properties\": [\r\n {\r\n \"name\": \"cardcode\",\r\n \"value\": \"Z064122\"\r\n },\r\n {\r\n \"name\": \"name\",\r\n \"value\": \"XXXXXX\"\r\n },\r\n {\r\n \"name\": \"groupcode\",\r\n \"value\": \"Prospect\"\r\n },\r\n {\r\n \"name\": \"currency\",\r\n \"value\": \"USD\"\r\n },\r\n {\r\n \"name\": \"database_company\",\r\n \"value\": \"XXXXXXXXX\"\r\n },\r\n {\r\n \"name\": \"push_to_crm_company_\",\r\n \"value\": \"Yes\"\r\n },\r\n {\r\n \"name\": \"turnover\",\r\n \"value\": \"0 - 4.99\"\r\n },\r\n {\r\n \"name\": \"bp_type\",\r\n \"value\": \"Lead\"\r\n },\r\n {\r\n \"name\": \"u_hosting\",\r\n \"value\": \"-\"\r\n },\r\n {\r\n \"name\": \"u_contractvalue\",\r\n \"value\": \"0.000000\"\r\n },\r\n {\r\n \"name\": \"u_contractrdate\",\r\n \"value\": \"0\"\r\n },\r\n {\r\n \"name\": \"hubspot_owner_id\",\r\n \"value\": \"XXXXXXXXXX\"\r\n },\r\n {\r\n \"name\": \"core_product\",\r\n \"value\": \"XXXXX\"\r\n },\r\n {\r\n \"name\": \"company_telephone_1\",\r\n \"value\": \"XXXXXXXXX\"\r\n },\r\n {\r\n \"name\": \"county_us\",\r\n \"value\": \"California\"\r\n },\r\n {\r\n \"name\": \"zip\",\r\n \"value\": \"XXXXXXXX\"\r\n },\r\n {\r\n \"name\": \"city\",\r\n \"value\": \"XXXXXXXXXX\"\r\n },\r\n {\r\n \"name\": \"country_crm\",\r\n \"value\": \"US\"\r\n },\r\n {\r\n \"name\": \"company_bde_owner\",\r\n \"value\": \"XXXXXXXXXXX\"\r\n }\r\n ]\r\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Note: I already tried adding below code, but still no success.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content