简体   繁体   English

在Restsharp中获得与Postman中不同的响应

[英]Getting different response in Restsharp then in Postman

I am getting a correct response when using Postman but when I use the generated restsharp code in Postman i get the following as a response "Not available at this moment". 我在使用Postman时得到正确的响应,但是当我在Postman中使用生成的restsharp代码时,得到以下响应作为“此刻不可用”。

The generated Code is the following: 生成的代码如下:

var client = new RestClient("https://allevents.in/api/index.php/events/web/q");
var request = new RestRequest(Method.POST);
request.AddHeader("Postman-Token", "e35b163d-19b5-bb1d-ddcc-b547411efeac");
request.AddHeader("Referer", "allevents.in");
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Accept", "application/json");
request.AddHeader("scheme", "https");
request.AddHeader("path", "/api/index.php/events/web/q");
request.AddHeader("method", "POST");
request.AddHeader("autority", "allevents.in");
request.AddParameter("undefined", "{\"venue\":\"0\",\"ids\":\"0\",\"type\":\"json\",\"city\":\"luxembourg\",\"edate\":\"\",\"page\":\"0\",\"keywords\":\"0\",\"sdate\":\"\",\"category\":\"parties\",\"city_display\":\"luxembourg\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

I have tried clearing the default parameters but had no success. 我尝试清除默认参数,但没有成功。

Thanks in advance 提前致谢

Solved 解决了

There were two missing cookies that were not shown in the postman interface.I have found them in the fiddler request and added them to the cookie container. 有两个丢失的cookie没有在邮递员界面中显示,我在提琴手的请求中找到了它们并将它们添加到cookie容器中。

Man, try remove the Postman-token. 老兄,请尝试删除邮递员令牌。

Before I remove this, I got "Not avaliable", After I remove I got the correct message... 在删除此消息之前,我收到了“不可用”,在删除之后,我得到了正确的消息...

{
  "request": {
    "venue": "0",
    "ids": "0",
    "type": "json",
    "city": "luxembourg",
    "edate": "",
    "page": "0",
    "keywords": "0",
    "sdate": "",
    "category": "parties",
    "city_display": "luxembourg",
    "rows": 50
  },
  "count": 50,
  "item": [
    {
      "event_id": "156123315020311",
      "eventname": "Soho - All Must Dance",
      "eventname_raw": "Soho - All Must Dance",
      "owner_id": "283436232149109",
      "thumb_url": "https://cdn-az.allevents.in/banners/8b8744b8ad6d3e89749c1276d0d37d60-rimg-w200-h200-gmir.jpg",
      .....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM