Skip to content

Adding headers at the request level #330

Open
@anbo65

Description

@anbo65

I understand that you can add headers at the client level (that get sent for every request) but how can I add a header at the
request level.

e.g. This code shows how DefaultRequestHeaders can be set, but what if I wanted to add a request level header for say a Correlation Id?

var graphClient = new GraphQLClient("https://api.github.com/graphql");
graphClient.DefaultRequestHeaders.Add("Authorization", $"bearer {gitHubAccessToken}");
//var test = await graphClient.GetIntrospectionQueryAsync();
var request = new GraphQLRequest
{
    Query = @"query { viewer { login } }"
};
var test = await graphClient.PostAsync(request);

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions