# C# RestSharp library Submit a Form Example

**URL:** <https://community.hubspot.com/t/c-restsharp-library-submit-a-form-example/15879>\
**Category:** APIs & Integrations\
**Tags:** developer-tools, forms\
**Created:** [August 21, 2019, 11:48pm UTC](https://community.hubspot.com/t/c-restsharp-library-submit-a-form-example/15879 "2019-08-21T23:48:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rvaladez](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rvaladez/32/63860_2.png) [@rvaladez](https://community.hubspot.com/u/rvaladez)\
**Post date:** [August 21, 2019, 11:48pm UTC](https://community.hubspot.com/t/c-restsharp-library-submit-a-form-example/15879/1 "2019-08-21T23:48:05Z")

</div>

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/](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 }  
}  
});

IRestResponse response = client.Execute(request);

But i am getting the next response.StatusCode: 0

“StatusCode: 0, Content-Type: , Content-Length: 0)”

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.”

---

<div class="post-metadata">

**Author:** ![lscanlan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lscanlan/32/66262_2.png) [@lscanlan](https://community.hubspot.com/u/lscanlan)\
**Post date:** [August 23, 2019, 4:48pm UTC](https://community.hubspot.com/t/c-restsharp-library-submit-a-form-example/15879/2 "2019-08-23T16:48:23Z")

</div>

Hi @rvaladez,

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](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](http://api.hubapi.com) . Our form submission endpoints are actually on a different domain. So that form submission URL is on [forms.hubspot.com](http://forms.hubspot.com) . Does your request work if you change:

```auto
var client = new RestClient("https://api.hubapi.com/");

```

to:

`var client = new RestClient("https://forms.hubspot.com/");`

If not, let me know and I can take another look.

---

<div class="post-metadata">

**Author:** ![rvaladez](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rvaladez/32/63860_2.png) [@rvaladez](https://community.hubspot.com/u/rvaladez)\
**Post date:** [August 23, 2019, 5:07pm UTC](https://community.hubspot.com/t/c-restsharp-library-submit-a-form-example/15879/3 "2019-08-23T17:07:21Z")

</div>

I tried the change, I had not noticed that it was another domain, but the result is still the same error.

I appreciate your help

---

<div class="post-metadata">

**Author:** ![lscanlan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lscanlan/32/66262_2.png) [@lscanlan](https://community.hubspot.com/u/lscanlan)\
**Post date:** [August 23, 2019, 10:34pm UTC](https://community.hubspot.com/t/c-restsharp-library-submit-a-form-example/15879/4 "2019-08-23T22:34:32Z")

</div>

Hi @rvaladez,

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](https://www.google.com/search?source=hp&ei=L19gXYCQH6Ln5gKpupuICw&q=C%23+RestSharp+System.PlatformNotSupportedException%3A+Operation+is+not+supported+on+this+platform&oq=C%23+RestSharp+System.PlatformNotSupportedException%3A+Operation+is+not+supported+on+this+platform&gs_l=psy-ab.3...436.23839..24392...0.0..0.99.274.3......0....2j1..gws-wiz.......0.bpwdAJQVbAQ&ved=0ahUKEwjA46qj_JnkAhWis1kKHSndBrEQ4dUDCAc&uact=5) . 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.

---

<div class="post-metadata">

**Author:** ![rvaladez](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rvaladez/32/63860_2.png) [@rvaladez](https://community.hubspot.com/u/rvaladez)\
**Post date:** [August 27, 2019, 2:52pm UTC](https://community.hubspot.com/t/c-restsharp-library-submit-a-form-example/15879/5 "2019-08-27T14:52:34Z")

</div>

I understand, I will review my configuration more thoroughly if I am missing something, if the result changes I will let you know.

I will also check GitHub.

We only need the integration with hubspot with the form submission, we are not currently integrating any other method of your Api.

Thank you

---

<div class="post-metadata">

**Author:** ![rvaladez](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rvaladez/32/63860_2.png) [@rvaladez](https://community.hubspot.com/u/rvaladez)\
**Post date:** [September 4, 2019, 3:21pm UTC](https://community.hubspot.com/t/c-restsharp-library-submit-a-form-example/15879/6 "2019-09-04T15:21:02Z")

</div>

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.

Thank you very much for your help!

Regards

---

<div class="post-metadata">

**Author:** ![lscanlan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lscanlan/32/66262_2.png) [@lscanlan](https://community.hubspot.com/u/lscanlan)\
**Post date:** [September 4, 2019, 6:08pm UTC](https://community.hubspot.com/t/c-restsharp-library-submit-a-form-example/15879/7 "2019-09-04T18:08:20Z")

</div>

That’s great, thank you for the follow-up!
