cURL request to "return" response

  • Thread starter Thread starter G-Oker
  • Start date Start date
G

G-Oker

Guest
Hello,

I am trying to construct a method which I can use for Multiple cURL calls, and then deal with the response. but I don't know how to "return" the response so I can carry out more work on it, so, I was hoping someone here could point out what i am doing incorrectly.

I have created this

public HttpWebRequest CURLRequest(string CURLURL)
{
////Create CURL client using RESTSharp
var client = new RestClient(CURLURL);
client.Timeout = -1;
var request = new RestRequest(Method.GET);

request.AddHeader("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(uid)));
////Deal with response
IRestResponse response = client.Execute(request);

var responseString = response.Content.ToString();
textBox1.AppendText("Reply is:"+ Environment.NewLine+ response.Content);
return null;
}


and I call this from a button press

private void button1_Click(object sender, EventArgs e)
{
try
{
textBox1.Text = "";
CURLURL = URL + "extra/";
HttpWebRequest request = CURLRequest(CURLURL); //create a client

.......

what I would like to do use the response in the button1_click , so I can keep the CURLRequest generic for use with other calls.

When I change

return null;

to

return responseString;

or

return response.Content;

I get the message

"cannot implicitly convert type 'string' to 'system.net.httpwebresquest'


Could someone advise me on how I can get CURLReqest to return the (XML) response, so I can then use it in Button1_click ?


Thank you

Continue reading...
 
Back
Top