[SOLVED] Creating a GET API call ...... equivalent MVC function to MVCFunctions.runner_post_request |
12/23/2023 5:34:42 AM |
ASPRunner.NET General questions | |
D
david powell author
HI, I am using this sample of code dynamic _params = XVar.Array(); to create an POST API call. I am modifying it to do a GET, but this function dynamic result = MVCFunctions.runner_get_request(url, _params) does not exist. There are of posts about MVCFunction lists, and I understand they are to be avoided and replaceable by a c# code function. Can anyone help me with what that c# syntax would be... or what the undocumented MVCFunction equivalent would be??? Many thanks! |
|
![]() |
Admin 12/23/2023 |
Why don't you use the sample C# code from the manual: |
D
|
david powell author 12/23/2023 |
Because trying to use RestSharp, which would be fine, I am still failing to get asprunner to compile, as it gives a series of errors starting with: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 Include file has using RestSharp; Test script has var client = new RestClient("http://localhost:8086/api/v1.php?table=customers&action=list"); I have tried using latest verion of ..net available on asprunner, and changed to visual studio 2019 , all to no avail. Hence trying to use the code above instead, but defeated by that because of the apparent absence of MVCFunctions.runner_get_request(url, _params) I have tried using c# script using https client but that fails because of an SSL connection error which I cant overcome. Each avenue seems to be out to defeat me! |
D
|
david powell author 12/26/2023 |
OK, I have tried a variety of methods to try and get API calls working programmatically. I couldnt get RestSharp to compile properly, probably because it requires Net Standard version 2.0.0.0 and doesnt like the versions which ASPrunner offers (though I may be wrong about this). Using the built in HTTPs functions produces SSL problems. However, I have managed to make it work using NewtonSoft.Json. I attach what I did to install this third party dll, and a couple of code fragments - one to get a list, one to do an insert, both using basic authentication. The coding is not pretty, but they do work for the APIs I need to interface with. I put it here so if you are stuck like I was you might find a way forward using this as a basis. Good luck!
string username = "user"; try } |