K
K
Karkes2021-09-07 22:28:21
API
Karkes, 2021-09-07 22:28:21

Do symbols appear during Rest request?

Wrote a request to the site

public static string UTCtime()
        {
            string url = "http://worldtimeapi.org/api/timezone/Europe/Berlin";
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            string response ;
            StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream());
            response = streamReader.ReadToEnd();
            streamReader.Close();
            IRoot myDeserializedClass = JsonConvert.DeserializeObject<IRoot>(response);
            string[] UTC = myDeserializedClass.utc_datetime.Split('.');
            string UTCg = UTC[0].Replace(":","%3A");
            Console.WriteLine(UTCg);
            return UTCg;
        }

, the request is being processed normally.
The result of this request is used in another request, and this is where the problems begin. The fact is that here is the value that should be sent in the subsequent request
2021-09-07T19%3A07%3A10
.
And here is the value that is sent after the fact
2021-09-07T19%3 25 A07%3 25 A10
.
What is the problem is not very clear. For greater clarity, the date that I get can be converted to another encoding . It was possible to implement it programmatically with a blunt replacement.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-09-08
@vabka

string UTCg = UTC[0].Replace(":","%3A");
Just remove this and other lines where escaping is done by hand.
When sending a request, the http client itself shields everything as it should.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question