'cannot use Post requests from restsharp including headers
I was like trying to make a post request using restsharp but every time I got no response...
the get request work just fine ... but every time I made a post request I ended up with no response .. here is my code :
var client = new RestClient("https://any_url_here");
//client.Timeout = -1;
var request = new RestRequest(Method.POST);
// request.RequestFormat = DataFormat.Json;
// request.AddBody(new{phoneNumber = textBox1.Text });
request.AddParameter("phoneNumber", textBox1.Text);
request.AddHeader("Authorization", "bcdhgyegdkj");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
client.UserAgent = "Dalvik/2.1.0 (Linux; U; Android 7.1.2; S8 Build/N6F26Q)";
request.AddHeader("Host", "any.site");
request.AddHeader("Content-Length", "22");
IRestResponse response = client.Execute(request);
richTextBox1.Text = response.Content.ToString();
I have tried almost every way but no use ... so I have commented some lines.. also I have tried a code from postman but it did not work too.
why I did not get any response or content? I rewrite the code in python and it just worked fine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|