简体   繁体   中英

Delphi: REST Request with BASIC authentication

I'm using TRESTClient/THTTPBasicAuthenticator/TRESTRequest/TRESTResponse to get data from a server.

With response Ok (200), instead of receiving JSON data, I get as content this:

<script type="text/javascript"> 
<!-- function redirectToIndex()
{       
var adresse = window.location.pathname.split('/');      
var httpURL = window.location.hostname + "/" + "app"; // redirect to root
var httpsURL = "https://" + httpURL;
window.location = httpsURL;
}
redirectToIndex();  //--> 

This is when TRESTRequest.Accept is empty. If I change for TRESTRequest.Accept := ' application/json ', I get an error

406 - Not Acceptable

Could you tell me what's wrong with my request?

Thank you Peter. I managed to clarify with the API support the BASIC Authentication using the correct login/password. The documentation was inaccurate. Access is now working as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM