将参数传递给 RestSharp GET 请求

Passing parameter to RestSharp GET request

我正在尝试与 Drupal 站点通信以访问特定节点。我正在使用 C# 和 RestSharp 来访问数据。我可以在 FireFox RestClient 中使用以下内容:

http://localhost/drupal/gpa/node?parameters[type]=product_activation

它returns 正确的节点类型。但是,我尝试使用 RestSharp 编写的所有代码都不起作用。我要么获得所有节点类型,要么获得 none。我使用的代码:

restClient = new RestClient(“http://localhost/drupal/gpa/node”);
RestRequest request = new RestRequest();

request.Method = Method.GET;
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-CSRF-Token", csrftoken);
request.AddHeader("Cookie", sessid);
request.AddParameter("type", "product_activation", ParameterType.GetOrPost);

var response = restClient.Execute(request);

这导致返回每个节点。并且,响应 uri 是:

{http://localhost/drupal/gpa/node?type=product_activation}

谁能解释如何更正参数传递以仅访问请求的类型?

我能够解决这个问题。通过一些调试编码,我注意到即使拉出所有节点,我正在寻找的类型也丢失了。这让我找到了 Drupal 系统,我发现节点不是 "published"。这意味着对于外界来说,这个节点是不存在的。因此,我无法取回它。一旦我制作了节点 "published":

,这段代码就起作用了
restClient = new RestClient(RestGetNodes);
RestRequest request = new RestRequest();

request.Method = Method.GET;
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-CSRF-Token", csrftoken);
request.AddHeader("Cookie", sessid);
request.AddParameter("parameters[type]", "product_activation");