I guys, i need to make a POST request but i been rejected with a Remote server Error: (416) Requested Range Not Satisfiable. with a request structured like this:
req.Method = "POST";
req.Host = "launches-api.endclothing.com";
req.KeepAlive = true;
req.ContentLength = sentData.Length;
req.Accept = "application/json, text/plain, */*";
req.ContentType = "application/json;charset=UTF-8";
req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36";
req.Headers["Origin"] = "https://launches.endclothing.com";
req.Headers["Sec-Fetch-Site"] = "same-site";
req.Headers["Sec-Fetch-Mode"] = "cors";
req.Headers["Sec-Fetch-Dest"] = "empty";
req.Headers["Access-Control-Allow-Origin"] = "https://launches.endclothing.com";
req.Referer = "https://launches.endclothing.com/";
req.Headers[HttpRequestHeader.AcceptEncoding] = "gzip, deflate, br";
req.Headers[HttpRequestHeader.AcceptLanguage] = "it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7";
The original POST request sniffed from Fiddler got some extra-headers which change at every request and them are mentioned in the OPTIONS package sent before making the request.
Fiddler POST request
OPTIONS package
So i don't know where to take that Headers i am missing in my request.
Can you please give me a tip?
Related
I want to run a URL and get the result.
I used the below code but it does not work correctly. It just returns the main website URL as a result.
this is the main page which has a blue box is called filenext. I get its link and this is what I want to get as a result.
WebClient client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
WebClient getNitroflareLink = new WebClient();
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream stream = response.GetResponseStream();
You should set Refererfrom the first URL for the second one.
var page = firstLink.LoadIt();
HttpWebRequest request = WebRequest.Create(Refererlink) as HttpWebRequest;
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36";
request.Referer = firstLink;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
I'm trying to send an HttpWebRequest To a website .
the request is pretty simple :
var req = (HttpWebRequest)WebRequest.Create("");
req.Host = "";
req.Method = "POST";
req.Accept = "";
req.UserAgent = "";
req.Referer = "";
var res = (HttpWebResponse)req.GetResponse();
but i'm getting 403 Forbidden Exception .
what i cannot understand is the request works perfectly using requests captures tools like Burpsuit etc ...
I didnt forget anything about the request , the method and the host etc is correct . and the useragent is the latest :
Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0
the request Works in my rdp which makes me think about the sender IP . but the issue is the request works with burpsuit and browsers as well .
any help ?
thanks
First of all sorry for my bad english.
Task is to authenticate in instagram with API. When I try to get a token after the user clicked "OK" I get 403 error from HttpWebResponse and I can't get my token:(. I don't know what to do. Help me please. And when I enter this link in me browser - it's ok
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://instagram.com" + url);
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36";
request.Method = "POST";
request.CookieContainer = cookies;
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
request.Headers.Add("Accept-Encoding: gzip, deflate");
request.Headers.Add("Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4");
request.Headers.Add("Cache-Control:max-age=0");
request.ContentType = "application/x-www-form-urlencoded";
request.Host = "instagram.com";
request.Headers.Add("Origin: https://instagram.com");
StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.Write("csrfmiddlewaretoken=" + par + "&username=LOGIN&password=PASSWORD");
writer.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //403 ERORR
You cannot get an access token by simply sending a username/password pair to the API! You have to direct a real user to the Instagram's authorization url, and after the user logged in successfully Instagram will send your application a code to be used for getting the access token.
More information: https://instagram.com/developer/authentication/
HttpClient client = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = true }) { };
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Add("ContentType", "audio/mpeg");
request.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
request.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36");
request.Headers.Add("Accept-Encoding", "gzip, deflate");
request.Headers.Add("Host", "fsa.zedge.net");
request.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
request.Headers.Add("Accept-Language", "en-US,en;q=0.8,vi;q=0.6");
request.Headers.Add("Cache-Control", "max-age=0");
request.Headers.Add("Connection", "keep-alive");
HttpResponseMessage response = await client.GetAsync(new Uri(url,UriKind.Absolute));
response.EnsureSuccessStatusCode();
string responseUri = response.RequestMessage.RequestUri.AbsoluteUri;
An exception of type 'System.Net.Http.HttpRequestException' occurred
in System.Net.Http.DLL but was not handled in user code
Additional information: Response status code does not indicate
success: 403 (Forbidden).
I have a URL but when I get it, it will move toward the other, and each time a URL is redirected URL, then it's different. And this URL work sessions every time it expires. So now every time I get a new URL, it just informed that the session fails
I want to sign in to a site when a link is clicked and then redirect the browser there with a signed in session. Im having some troubles and here is what Ive tried:
First I get the session cookies from the login site:
CookieContainer cookies= new CookieContainer();
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://someuri.com");
myHttpWebRequest.CookieContainer = cookies;
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
myHttpWebResponse.Close();
Then I post to the sign in page to get signed in:
HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create("http://signInURL.com");
getRequest.CookieContainer = cookies;
getRequest.Method = WebRequestMethods.Http.Post;
getRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
getRequest.AllowWriteStreamBuffering = true;
getRequest.ProtocolVersion = HttpVersion.Version11;
getRequest.AllowAutoRedirect = true;
getRequest.ContentType = "application/x-www-form-urlencoded";
byte[] byteArray = Encoding.ASCII.GetBytes(PostParameterStringWithSignInInfo);
getRequest.ContentLength = byteArray.Length;
Stream newStream = getRequest.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.Length);
newStream.Close();
HttpWebResponse getResponse = (HttpWebResponse)getRequest.GetResponse();
Then I figured I need to set the cookies to the client:
CookieCollection cooki = getRequest.CookieContainer.GetCookies(new Uri("http://someUri.com"));
for(int i = 0; i < cooki.Count; i++)
{
Cookie c = cooki[i];
Response.Cookies.Add(new HttpCookie(c.Name, c.Value));
}
And then redirect to where you end up being signed in:
Response.Redirect("http://URLwhenBeingSignedIn.com");
This doesnt work. When redirected Im still logged out.
Tried to do this with Fiddler and succeeded to sign in and get redirected:
Get the session cookies:
GET / HTTP/1.1
Content-type: application/x-www-form-urlencoded
Host: someuri.com
Post to the sign in page to get signed in:
POST /signIn HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Referer: http://someuri.com
Accept-Language: en-GB,en;q=0.7,tr;q=0.3
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Content-Length: 90
DNT: 1
Host: signInURL.com
Pragma: no-cache
Cookie: JSESSIONID=fromBefore; Cookie2=fromBefore
PostParameterStringWithSignInInfo
Perhaps there's an easier way than the one I thought of now that you can see the fiddler requests that works, if so I'm happy to see it.