Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OData response with custom ODataOutputFormatter #2843

Open
sarvancse1987 opened this issue Jun 18, 2024 · 2 comments
Open

OData response with custom ODataOutputFormatter #2843

sarvancse1987 opened this issue Jun 18, 2024 · 2 comments
Assignees

Comments

@sarvancse1987
Copy link

var oDataResponse = new ODataResponse
{
Items = transformedResults as IEnumerable,
Count = response.TotalRecords,
NextLink = response.ContinuationToken
};

return Ok(responses);

needs to return the cosmodb continuationtoken for fetch the next set of records

@habbes
Copy link
Contributor

habbes commented Jun 18, 2024

Hello @sarvancse1987 could you share more information about the actual problem you're facing, any error you observed, expected and actual behaviour, etc?

@habbes habbes self-assigned this Jun 18, 2024
@sarvancse1987
Copy link
Author

sarvancse1987 commented Jun 19, 2024

Hi @habbes , Thank you so much, to here the issue.

[EnableQuery(
AllowedQueryOptions = AllowedQueryOptions.None,
HandleReferenceNavigationPropertyExpandFilter = false,
HandleNullPropagation = HandleNullPropagationOption.False,
AllowedFunctions = AllowedFunctions.None
)]
[SwaggerOperationFilter(typeof(ODataOperationFilter))]
[SwaggerOperation(
Summary = "Get ValueChain Events History",
Description = "

Get VC events history data for the specified filter condition.

",
OperationId = "GetEventsHistory",
Tags = new[] { "EventsHistory" }
)]
[HttpGet("api/History/Get")]
[ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.InternalServerError)]
public async Task Get(ODataQueryOptions options, string continuationToken = null)
{
try
{
var queryKeys = HttpContext.Request.Query.Keys;
if (queryKeys.Any(key => key.StartsWith("$")))
{
_logger.LogWarning("Query options are not allowed.");
return BadRequest("Query options are not allowed.");
}

    var sql = _translator.Translate(options, TranslateOptions.ALL);

    var response = await _eventsHistoryService.GetEventsAsync<VCEventResponse>(sql, continuationToken);

    **var queryResult = new CosmosQueryResult<VCEventResponse>
    {
        Items = response.Items,
        ContinuationToken = Uri.EscapeDataString(response.ContinuationToken),
        TotalRecords = response.TotalRecords
    };
    return Ok(queryResult);**
}
catch (Exception ex)
{
    _logger.LogError("Exception occurred while getting events history data - " + ex.Message);
    throw new Exception("Exception occurred while getting events history data - " + ex.Message);
}

}

I would like to return the response with Odata features, and examples (select, filter, top, skip).
Presently in this method, the features (select, filter, top, skip) will not support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants