QueryContext Explanation

Hello!

I am attempting to change some of the headers for requests through the QueryContext in the Client Library. I cannot seem to figure out how to pass through IsFlatten or Languages through to my requests.

For example:
public async Task GetAsync(string id, QueryContext context = null)
{
Guard.NotNullOrEmpty(id, nameof(id));

        var response = await RequestAsync(HttpMethod.Get, BuildContentUrl($"{id}/"), context: context);
        var check = await response.Content.ReadAsStringAsync();
        return await response.Content.ReadAsJsonAsync<TEntity>();
    }

QueryContext is passed in as a parameter, but how is that object actually filled? I know I am missing something dumb here…

Thank you,
Blake

QueryContext is probably the wrong name from the client perspective.

You can create a context like this:

var ctx = QueryContext.Default.Flatten();

And then just pass it in as an parameter.

1 Like

Understood, that worked thank you.