Skip to content

How to posting payload with long OData query parameters (>1024 chars) #2887

Open

Description

@ernesto-manoni

Context
I'm working on an OData endpoint that should accept both:
an OData filter query (e.g. $filter=...)
a JSON payload in the request body (to post additional data).

example
POST /api/Documents?$filter=Matricola_x0020sampleslongquery

Payload
{
"document": {
"id": 123,
"title": "Document"
}
}

Controller EndPoint
public IQueryable Post(ODataQueryOptions queryOptions, Document document)
{
// [do something]
return somethingDocumentDto;
}

When the $filter or other query params becomes too long (more than 1024 characters), the request fails due to URL length limits.
To bypass this, I tried to move the OData query into the body and manually parse it using IODataQueryOptionsParser, but request is converted into a GET losing payload.

Is there a way to posting both a large query filter and and a payload in a single POST request?

Thanks

Activity

  1. habbes commented on Nov 11, 2025

    @habbes
    Contributor

    Hello @ernesto-manoni I was going to share that you can use the POST /$query endpoint and move the query to the request body as documented here: https://learn.microsoft.com/en-us/odata/webapi/query-options-in-request-body

    But that would indeed route to a Get action in your controller. In your case you want to include both the long query and request payload to the body. I don't understand the part where you say it converts the request into a GET and losing payload. Could you share a repro?

    Do you know exactly how long the query params were? I think we should support way more than 1024 characters.

    One workaround I can think of is to use batch operations, using a JSON path or multipart-form syntax. While that's usually meant sending multiple OData requests in a single HTTP request, you do include both the request endpoints (include query params) and payload in the overall HTTP body. If you control the requests that the clients make, it could be a workaround.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions