Hi
I have issue with GET endpoint which accepts DateTime as parameter. I have microservices 2 A and B. The endpoint is implemented by A and called by B. For calling I use dynamic HttpApiClient. When DateTime passed to http client as parameter, the DateTime is stringified to string with ToString method. Then the string passed to url parameters pasrt without encoded to url format. That leads, when DaeTime stringified to 'dd/MM/yy hh:mm:ss' format, endpoint is not found because dd MM and yy are parsed as segments of url path.
Is that a bug in http client? I checked ClientProxyUrlBuilder and I think that it should use HttpUtility.UrlEncode for every passed value.ToString() - snippet
- ABP Framework version: v4.4.0
- UI type: Angular
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): separate
- Steps to reproduce the issue:
- Create GET endpoint which accepts DateTime as parameter
- Reference HttpApiClient project/package in another application or try to use client in the same application with the endpoint
- Add call of the endpoint
4 Answer(s)
-
0
hi
I think this is design.
https://github.com/abpframework/abp/pull/8599
endpoint is not found because dd MM and yy are parsed as segments of url path.
Can you share the code of your endpoint?
-
0
Sure,
Controller
[HttpGet] [Route("by-dateTime/{utcDateTime}")] public async Task<RecordDto> GetRecordByDateTime(DateTime utcDateTime) { return await _recordAppService.GetRecordByDateTime(utcDateTime); }
Application service
public async Task<RecordDto> GetRecordByDateTime([DisableDateTimeNormalization] DateTime utcDateTime) { var record = await _recordRepository.GetAsync(i => i.UtcDateTime == utcDateTime); return await ObjectMapper.Map<RecordDto>(record); }
Microservice A gets call of url path
/api/records/by-dateTime/27/12/2021 10:00:00
. The format of date time is default format in InvariantCulture used by HttpClient.But the issue relates not only to DateTime. It relates to any object which has special symbols in string presentation. For example, if we replace DateTime with string parameter, which value has space symbol inside, then we get problem again, because space can not be used without encoding in url path.
-
0
hi
I will check and fix that. Thanks
-
0
https://github.com/abpframework/abp/pull/11081/