HttpWebRequest := HttpWebRequest.Create('https://api.order'); HttpWebRequest.Timeout := 30000; HttpWebRequest.Headers.Add('Authorization','Basic username-pass'); HttpWebRequest.PreAuthenticate := TRUE; HttpWebRequest.ContentType := 'application/json'; HttpWebRequest.Method := 'POST'; CookieContainer := CookieContainer.CookieContainer; HttpWebRequest.CookieContainer := CookieContainer; RequestStr := HttpWebRequest.GetRequestStream; StreamWriter := StreamWriter.StreamWriter(RequestStr,Encoding.UTF8); StreamWriter.Write(JSonText); StreamWriter.Flush; HttpWebResponse := HttpWebRequest.GetResponse; GetResponseStream(HttpWebResponse,ResponseString);
Answers
The username-pass need to be encoded in Base64. You can use Fiddler Text wizard for this or other tools that convert string to Base64.
you should convert username:password to Base64 then put the result into below headers
HttpWebRequest.Headers.Add('Authorization','Basic UsernamePasswordinBase64');