Skip to content

Override the default ACCEPT header value #670

@amorrowbellarmine

Description

@amorrowbellarmine

I'm trying to use the GraphQL.Client library in a project that interacts with a 3rd party API. Currently, the API only accepts application/json for the ACCEPT header. Is there an easy way to override the library's default value of application/graphql-response+json, application/json (https://github.com/graphql-dotnet/graphql-client/blob/master/src/GraphQL.Client/GraphQLHttpRequest.cs#L45)? I tried the following code, but it did not work.

using var graphQLClient = new GraphQLHttpClient("https://3rdpartyservice.com/graphql", new NewtonsoftJsonSerializer());
graphQLClient.HttpClient.DefaultRequestHeaders.Accept.Clear();
graphQLClient.HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

I understand the library was updated to follow the spec for GraphQL over HTTP (#459), but that is still in the draft phase, and it appears the company that maintains the API hasn't implemented the spec's requirement. I've opened a ticket with the company to see if they can update their API to more closely conform to the draft spec, In the meantime, I wanted to see if there was an easy way to get my project working.

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