Use c-sharp code to post to TurnkeyRest
(Created page with "<pre> var cli = new System.Net.Http.HttpClient(); var requestContent = new System.Net.Http.MultipartFormDataContent("--BOUNDARY"); requestConte...")
 
(Automatically adding template at the end of the page.)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<pre>
<pre>
          var cli = new System.Net.Http.HttpClient();
  var cli = new System.Net.Http.HttpClient();
          var requestContent = new System.Net.Http.MultipartFormDataContent("--BOUNDARY");
  var requestContent = new System.Net.Http.MultipartFormDataContent("--BOUNDARY");




          requestContent.Add(new System.Net.Http.StringContent("DataToAmountVMCol"), "Amount");
  requestContent.Add(new System.Net.Http.StringContent("DataToAmountVMCol"), "Amount");
          requestContent.Add(new System.Net.Http.StringContent("DataToMessageVMCol"), "Message");
  requestContent.Add(new System.Net.Http.StringContent("DataToMessageVMCol"), "Message");
          requestContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("multipart/form-data; boundary=--BOUNDARY");
  requestContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("multipart/form-data; boundary=--BOUNDARY");


          var url= "https://yoursystem";
  var url= "https://yoursystem";
          var res = cli.PostAsync(url+ "/TurnkeyRest/Post?command=Consume&id=" + TurnkeySettingFromFile.TurnKeySetting_PortalGuid, requestContent).Result;
  var res = cli.PostAsync(url+ "/TurnkeyRest/Post?command=Consume&id=" + TurnkeySettingFromFile.TurnKeySetting_PortalGuid, requestContent).Result;
          if (res.IsSuccessStatusCode)
  if (res.IsSuccessStatusCode)
          {
  {
          }
  }
 
</pre>It is important to supply a boundary token in the request and header. Otherwise, the Turnkey server will not parse the values (this is the same for all asp.net servers).
</pre>
[[Category:C-Sharp]]
[[Category:MDriven Turnkey]]
{{Edited|July|12|2024}}

Latest revision as of 15:49, 10 February 2024

  var cli = new System.Net.Http.HttpClient();
  var requestContent = new System.Net.Http.MultipartFormDataContent("--BOUNDARY");


  requestContent.Add(new System.Net.Http.StringContent("DataToAmountVMCol"), "Amount");
  requestContent.Add(new System.Net.Http.StringContent("DataToMessageVMCol"), "Message");
  requestContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("multipart/form-data; boundary=--BOUNDARY");

  var url= "https://yoursystem";
  var res = cli.PostAsync(url+ "/TurnkeyRest/Post?command=Consume&id=" + TurnkeySettingFromFile.TurnKeySetting_PortalGuid, requestContent).Result;
  if (res.IsSuccessStatusCode)
  {
  }

It is important to supply a boundary token in the request and header. Otherwise, the Turnkey server will not parse the values (this is the same for all asp.net servers).

This page was edited more than 11 months ago on 02/10/2024. What links here