The ‘Referer’ header must be modified using the appropriate property or method

By On

"I am getting an error that says 'The 'Referer' header must be modified using the appropriate property or method'. I don't understand the meaning of this. The code seems pretty simple but i do not understand why it isnt working for me. Does anyone know what the cause of this is. Here is a copy of the C# code that I am using to make the request. var request = (HttpWebRequest)WebRequest.Create(url);

	var request = (HttpWebRequest)WebRequest.Create(url);
	request.Headers.Add(""Proxy-Authorization"", ""Basic "" + encodedApiKey);
	request.Referer = REFERERURLROOT + productSku;
	request.Proxy = myProxy;
	request.PreAuthenticate = true;
	request.AllowAutoRedirect = false;
	request.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

	var apiresp = request.GetResponse();"

1 Answer

- Advertisment -
SEMrush
Answered By William Rossbach On

The error is telling you that you are not to set the referrer header using the standard headers object. You need to call the property of the request object and set the header this way. The solution is to use request.