// Authorization HttpWebRequest := HttpWebRequest.HttpWebRequest; HttpWebRequest := HttpWebRequest.Create('*URL From Server*'); HttpWebRequest.ContentType := 'application/json'; HttpWebRequest.Method := 'POST'; HttpWebRequest.Headers.Add('Authorization',BearerTok); // Create JSON AddBodyAsTextWithEncoding(HttpWebRequest,GetArticelExample, Encoding.UTF8); // Get response HttpWebResponse := HttpWebResponse.HttpWebResponse; HttpWebResponse := HttpWebRequest.GetResponse; HttpResStatus := HttpWebResponse.StatusCode(); // Read response CLEAR(Response); ResStream := HttpWebResponse.GetResponseStream(); ResStreamReader := ResStreamReader.StreamReader(ResStream,TextEncoding.UTF8); Response := ResStreamReader.ReadToEnd(); HttpWebResponse.Close; HttpWebResponse.Dispose;
Answers
Put this line into TRY function:
Add function to catch an exception:
And handle an exception: