我需要从响应字段(香蕉蛋糕流行)获得一个文本,但不知道如何使用GraphQL nuget。我发现了类似于
var graphQLClient = new GraphQLHttpClient("url", new NewtonsoftJsonSerializer());
graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", "Bearer token");
graphQLClient.HttpClient.DefaultRequestHeaders.Add("Accept", "application/json");
var heroRequest = new GraphQLRequest
{
Query = @"
{query(
$propIdArray: [Uuid!], $objectIdArray: [Uuid!], $ts: String){
propertyViews(
propIdArray: $propIdArray, objectIdArray: $objectIdArray, ts: $ts
) {
id,
value,
valueTypeId
}
}}"
};
var graphQLResponse = await graphQLClient.SendQueryAsync<object>(heroRequest);但它没有给我任何东西。Banana Cake Pop页面的requset和变量以及响应看起来类似于这个香蕉蛋糕弹屏
发布于 2022-11-16 03:59:32
事实证明,这个解决办法非常简单。只需在heroRequest中添加一个变量属性。现在,请求方法如下所示
var myRequest = new GraphQLRequest
{
Query = File.ReadAllText(path),
Variables = new
{
ts = string.Empty,
filterObject = new { parentId = $"{parentId}" },
sort = new { orders = new[] { new { direction = "ASC", property = "name" } } }
}
};
var graphQLResponse = _graphQLClient.SendQueryAsync<object>(myRequest);https://stackoverflow.com/questions/74148813
复制相似问题