2
我使用此代碼,它利用odata4j ODataClientRequest
和ODataConsumer
試圖調用需要身份驗證OData服務:如何添加頁眉信息ODataConsumer在odata4j?
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
?