How to use Curl with C#, windows forms application

Question:

I'm trying to integrate my desktop application with an online tool (ScrumWise), but they use Curl, I'm not able to consume the rest.

curl https://api.scrumwise.com/service/api/v1/getData -k
  -u bob@example.com:69C0A6A9E957B6398BD8C62F3B67C95005CA...
  -d "projectIDs=729-11230-1,729-31745-129"
  -d "includeProperties=Project.backlogItems,BacklogItem.tasks"

I'm having difficulty in this second line here

-u bob@example.com:69C0A6A9E957B6398BD8C62F3B67C95005CA

how to transcribe this Curl in C#?

Answer:

You don't exactly need to use cURL to do this. You can use RestSharp which is simpler to use:

var cookie = new CookieContainer();
var client = new RestClient("https://api.scrumwise.com/service/api/v1/getData")
{
    Authenticator = new HttpBasicAuthenticator("bob@example.com", "69C0A6A9E957B6398BD8C62F3B67C95005CA"),
    CookieContainer = cookie
};

var request = new RestRequest(Method.GET);
request.AddParameter("application/x-www-form-urlencoded", "projectID=729-11230-1", ParameterType.RequestBody);
request.AddParameter("application/x-www-form-urlencoded", "name=Example backlog item 1", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

Don't forget that you need to generate your own API Key. The one you are testing is just an example from the ScrumWise documentation .

Scroll to Top