0

This is my curl command:

curl --insecure https://api.github.com/user?access_token=xxx

Is there a way to convert this into a C# code? I've tried various solutions, but all failed. I think the problem is the --insecure parameter.

This is my code:

String goodUrl = "http://www.google.com";
        String badUrl = "https://api.github.com/user?access_token=36905f6fffa42341c2e6fd12655295f2b4d25";
        var json1 = new WebClient().DownloadString(goodUrl);
        var json2 = new WebClient().DownloadString(badUrl);

GoodUrl is working fine, badUrl not. The error is "protocol violation".

user840718
  • 1,563
  • 6
  • 29
  • 54
  • Do you just want the html or are you looking to download a file? – Pseudonym Mar 26 '14 at 14:17
  • The output is just in json format. I have to put the result into a simple var. – user840718 Mar 26 '14 at 14:18
  • Have a look at the accepted answer to this question, it shows a couple of ways to do something like this in C#: http://stackoverflow.com/questions/7929013/making-a-curl-call-in-c-sharp – andyp Mar 26 '14 at 20:49

1 Answers1

0

Try this on for size:

var json = new WebClient().DownloadString("url");
Pseudonym
  • 2,052
  • 2
  • 17
  • 38