我的要求是使用另一个读取 api API1
(使用 NTLM Auth 的 OData 响应)API2
(目前在开发中,可以是使用 OAuth 的 OData 或 JSON 输出)
我正在构建的原因API2
是消费者API1
不支持 NTLM 并且仅支持 OAuth。
源 API1 的输出是这样的,如果您注意到最后有一个指向下一页的链接。
{
"odata.metadata": "https://abc/xyz/odata/$metadata#MA_C_X_Request",
"value": [
{
"RequestID": 1,
"RequestStatus": "Rejected – corrections needed",
"ECType": "c",
"Source": "2323",
"SourceType": "2323",
"Reason": "Final - 1 ready"
},
{
"RequestID": 2,
"RequestStatus": " review",
"ECType": "c",
"Source": "3232",
"SourceType": "232",
"Reason": "Final - 2 ready"
},
{
"RequestID": 3,
"RequestStatus": "in progress",
"ECType": "c",
"Source": "2323",
"SourceType": "2322",
"Reason": "Final - 3 ready"
},
{
"RequestID": 4,
"RequestStatus": "in progress",
"ECType": "c",
"Source": "2323",
"SourceType": "2323",
"Reason": "Final - 4 ready"
}
],
"odata.nextLink": "https://abc/xyz/odata/MA_C_X_Request?from=&ReqID=&$skip=100"
}
我试图构建的 wapper 是这样的.net core 3.1
:
public class MA_C_XController : Controller
{
[EnableQuery(PageSize = 500)]
[HttpGet]
[Route("MA_C_Request")]
[ODataRoute("MA_C_Request")]
public async Task<IActionResult> GetMA_C_Request(DateTime? from, string ReqID)
{
var client = new RestClient("https://abc/xyz/odata/MA_C_X_Request?from=&ReqID=");
var request = new RestRequest(Method.GET);
client.Authenticator = new NtlmAuthenticator();
IRestResponse response = await client.ExecuteAsync(request);
return Ok(response);
}
}
但由于不支持响应,我收到错误消息。我确实想创建一个实体集并通读响应,因为我要调用近 15-20 个 API,因此希望有一个通用方法可以按原样转换 OData 响应。特别是下一页链接应该是输出的一部分API2
。这甚至可能吗?