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}”;
// 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?