Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pass optional parameters as params
#1
I'm using the following code to send HTTP requests, but always get the following error:

StatusCode: 400, ReasonPhrase: 'BadRequest', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Date: Sun, 05 May 2024 21:45:56 GMT
  Server: Au
  Content-Type: text/plain; charset=utf-8
  Content-Length: 27
}


The args parameter can have zero or more arguments. In the following example, there are zero arguments.
 
Code:
Copy      Help
//.
script.setup(trayIcon: true, sleepExit: true, exitKey: KKey.Pause);
//..

string s="hello";
string r = internet.http.Get($"http://localhost:4455/test2?t={s}").Text(); 
print.it(r);



Use HTTP server: https://www.quickmacros.com/forum/showth...6#pid36746
Code:
Copy      Help
// class "Function2.cs"

static partial class Functions
{
    public static string test2(string t, params object[] args)
    {

        print.it(args.Length);
        return t;
    }

    
    public static string test2(string t)
    {

        return t;
    }
}


Messages In This Thread
pass optional parameters as params - by Davider - 05-05-2024, 09:47 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)