# c# winform StatusCode: 405, ReasonPhrase: Method Not Allowed

**URL:** <https://community.hubspot.com/t/c-winform-statuscode-405-reasonphrase-method-not-allowed/107032>\
**Category:** APIs & Integrations\
**Tags:** starter\
**Created:** [May 13, 2024, 4:56pm UTC](https://community.hubspot.com/t/c-winform-statuscode-405-reasonphrase-method-not-allowed/107032 "2024-05-13T16:56:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vagder](https://avatars.discourse-cdn.com/v4/letter/v/8baadc/32.png) [@vagder](https://community.hubspot.com/u/vagder)\
**Post date:** [May 13, 2024, 4:56pm UTC](https://community.hubspot.com/t/c-winform-statuscode-405-reasonphrase-method-not-allowed/107032/1 "2024-05-13T16:56:30Z")

</div>

Hi to all,

I am new to hubspot integration.

I want to update the custome name but i have an error StatusCode: 405, ReasonPhrase: ‘Method Not Allowed’

My Code is very simple:

private async void upd()  
{  
// Your HubSpot API key  
string apiKey = BearerToken;

// Company ID you want to update  
string companyId = “123456789”;

// URL of the HubSpot company endpoint  
string apiUrl = $“[https://api.hubapi.com/companies/v2/companies/{companyId}?hapikey={apiKey}](https://api.hubapi.com/companies/v2/companies/%7BcompanyId%7D?hapikey=%7BapiKey%7D)”;

// JSON payload containing the updated company data  
string jsonData = “{\“properties\”: {\“name\”: \“my new name\”}}”;

// Create a HttpClient instance  
using (HttpClient client = new HttpClient())  
{  
try  
{  
var request = new HttpRequestMessage  
{  
Method = HttpMethod.Patch,  
RequestUri = new Uri(apiUrl),  
Content = new StringContent(jsonData, Encoding.UTF8, “application/json”)  
};

HttpResponseMessage response = await client.SendAsync(request);if (response.IsSuccessStatusCode)  
{  
Console.WriteLine(“Company data updated successfully.”);  
}  
else  
{  
Console.WriteLine($“Error: {response.StatusCode} - {response.ReasonPhrase}”);  
}  
}  
catch (Exception ex)  
{  
Console.WriteLine($“Error: {ex.Message}”);  
}  
}  
}

What am i missing?

---

<div class="post-metadata">

**Author:** ![vagder](https://avatars.discourse-cdn.com/v4/letter/v/8baadc/32.png) [@vagder](https://community.hubspot.com/u/vagder)\
**Post date:** [May 14, 2024, 4:43pm UTC](https://community.hubspot.com/t/c-winform-statuscode-405-reasonphrase-method-not-allowed/107032/2 "2024-05-14T16:43:45Z")

</div>

i changed the url to: “[https://api.hubapi.com/crm/v3/objects/companies/](https://api.hubapi.com/crm/v3/objects/companies/)” and worked
