I use ASP.NET Core to consume GraphQL API and everything working fine, just I need pass the header because I need to use Arabica language and I don't know how I can pass it.
So I need to change language to "ar" when header is passing.
[HttpPost]
public async Task<IActionResult> Tracking(string code)
{
var options = new GraphQLHttpClientOptions
{
EndPoint = new Uri("https://EndPoint/graphql"),
// Add any additional configuration options here
};
var client = new GraphQLHttpClient(options, new NewtonsoftJsonSerializer());
var query = @"
query {
shipment(code: """ + code + @""") {
id
code
customerDue
createdAt
collected
paidToCustomer
paidToDeliveryAgent
}
}";
var request = new GraphQLRequest
{
Query = query
};
var response = await client.SendQueryAsync<dynamic>(request);
if (response.Errors != null) {
foreach (var error in response.Errors)
{
Console.WriteLine($"GraphQL Error: {error.Message}");
}
return NotFound();
}
else
{
var data = response.Data;
var shipment = new Shipment
{
id = data.shipment.id,
code = data.shipment.code,
customerDue = data.shipment.customerDue,
createdAt = data.shipment.createdAt,
collected = data.shipment.collected,
paidToCustomer = data.shipment.paidToCustomer,
paidToDeliveryAgent = data.shipment.paidToDeliveryAgent
};
return View(shipment);
}
return View();
}
So I need to pass content-language: ‘ar’
where can I put it?
Thanks for help.