This is my Code but is not working, Whats could be the problem?? I´m new in Hubspot integrations
var client = new RestClient("https://api.hubapi.com/"); var request = new RestRequest("uploads/form/v2/{PortalId}/{formGuid}", Method.POST); request.AddUrlSegment("portalId", "miportalId"); request.AddUrlSegment("formGuid", "miformGuid"); request.AddQueryParameter("hapikey", "mihapiKey");
request.AddBody(new { properties = new[]
{
new { property = "firstname", value = firstName ?? string.Empty }, new { property = "lastname", value = lastName ?? string.Empty }, new { property = "email", value = email }, new { property = "lifecyclestage", value = stage }, new { property = "company", value = company }, new { property = "ubicaci_n", value = stateName }, new { property = "centro_de_interes", value = locationName },
new { property = "me_interesa", value = answerInterest }, new { property = "puesto", value = answerTitle ?? string.Empty }, // Puesto new { property = "rea_de_trabajo", value = answerArea ?? string.Empty }, new { property = "necesito_un_espacio_para", value = answerSpace ?? string.Empty }, new { property = "dentro_de_cu_nto_tiempo_necesitas_el_espacio_", value = answerTime ?? string.Empty }, new { property = "tiempo_aproximado_de_contrato", value = answerTimeStay ?? string.Empty } } });
Error Exception: {System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Net.SystemWebProxy.GetProxy(Uri destination) at System.Net.ServicePointManager.ProxyAddressIfNecessary(Uri& address, IWebProxy proxy) at System.Net.ServicePointManager.FindServicePoint(Uri address, IWebProxy proxy) at System.Net.HttpWebRequest.get_ServicePoint() at RestSharp.Http.ConfigureWebRequest(String method, Uri url) at RestSharp.Http.PostPutInternal(String method) at RestSharp.Http.AsPost(String httpMethod) at RestSharp.RestClient.DoExecuteAsPost(IHttp http, String method) at RestSharp.RestClient.Execute(IRestRequest request, String httpMethod, Func`3 getResponse)}
Error Message: "Operation is not supported on this platform."
I'm not as familiar with C# but I did want to point out something that could be causing your error. It looks like you're trying to use the form submission endpoint documented here: https://developers.hubspot.com/docs/methods/forms/submit_form. And it also looks like you're trying to submit the request to api.hubapi.com . Our form submission endpoints are actually on a different domain. So that form submission URL is on forms.hubspot.com . Does your request work if you change:
var client = new RestClient("https://api.hubapi.com/");
to:
var client = new RestClient("https://forms.hubspot.com/");
I'm trying to understand if this error is getting thrown on our side or if it's something that's happening before it gets to our API. I did a search for that error and a few things come up: link to Google search . A status code 0 sounds like the request was canceled, and so it never made it to our API, which I would tend to think means something is going wrong before the request gets sent. But if I'm misunderstanding, definitely let me know. Could it be that you need to update something in your setup? I'm not sure if that search helps, but there are some GitHub threads that come up there. The top result is a pretty long thread, but I think they found a solution.
One other thing that's worth testing here is whether you're getting this error when making API calls to other HubSpot endpoints. If you're not, and this error is only happening for the form submission endpoint, that's something we'll want to look at. But if this is happening whenever you use this code to make any request to a HubSpot API, I'd think it's probably worth looking through that GitHub thread.
The problem has already been resolved, the problem was caused by an error in a version of the C# RestClient. Once the library was updated to the latest version, the call to hubspot worked correctly.