1

I want to use the following cURL command from python in C#, but I haven't found any way to do so.

$ curl --data "type=AUTH&code=CODE" https://example.com

I hope you can help me out with this issue I'm facing.

1
  • 1
    If you insist on using cUrl, look into Process.Start() - however using the .Net builtin methods like HttpClient would integrate way easier. Commented Oct 6, 2018 at 15:52

1 Answer 1

2

As pointed out by @Filburt you can use HttpClient to post data using C#

    using (var client = new HttpClient())
    {
        client.BaseAddress = new Uri("https://example.com");
        var content = new FormUrlEncodedContent(new[]
        {
            new KeyValuePair<string, string>("type", "AUTH"),
            new KeyValuePair<string, string>("code", "CODE")
        });
        var result = await client.PostAsync("", content);
        string resultContent = await result.Content.ReadAsStringAsync();
        Console.WriteLine(resultContent);
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.