我正在使用此代码,它利用 odata4jODataClientRequest
并ODataConsumer
尝试调用需要身份验证的 OData 服务:
String url = "https://mylocalhost/api/odata/People()?$filter=PID%20eq%20'10'";
Map<String, String> headers = new HashMap<String, String>();
headers.put("AccountID", "100");
ODataClientRequest clientRequest = new ODataClientRequest("GET", url, headers, null, null);
ODataConsumer consumer = ODataConsumer.create(url);
for(OEntity entity : consumer.getEntities("People").execute()){
但是,我收到了身份验证错误,因为服务器正在请求标头身份验证信息。如何创建ODataConsumer
包含所需授权标头信息的我的?