Cannot use WebClient.DownloadString when address variable include "/"

87 Views Asked by At

i'm trying to send a request to my rabbitmq service in my automated tests, using WebClient object.

code works perfectly on my local machine when running tests in debug mode in visual studio.

when running tests in jenkins, using MSTest, web call returns 404. the reason is that url address includes a "/" char. i tried several options, as replacing this char with %2F and using system encoding. everything tried worked locally and failed miserably on build server

var headerValue = "XXX";
var url = "http://SERVER/api/exchanges/%2F/SOME/OTHER/INFO";
var req = new WebClient();
req.Headers["SOMEHEADER"] = headerValue;
var s = req.DownloadString(url);

looking for information about root cause for that phenomenon or solutions for this to work in jenkins

EDIT: this is not duplication of other questions since, as i mentions, code works perfectly on local machine, and the answers given in the other questions didn't helped solving the problem on remote server. other question

0

There are 0 best solutions below