发布请求 C# 不起作用 - 401错误请求

问题描述

我正在尝试通过 POST 请求从 Twilio API 获得响应:

https://analytics.ytica.com/gdc/app/projects/{{WorkSpaceID}}/execute/raw

我在 API 中传递令牌作为从 https://analytics.ytica.com/gdc/account/token 生成的标头。

我正在调用 API,使用以下代码行:

var client = new RestClient("https://analytics.ytica.com/gdc/app/projects/{{WorkspaceID}}/execute/raw");
client.Timeout = -1;

var request = new RestRequest(Method.POST);
request.AddHeader("Accept","application/json");
request.AddHeader("Content-Type","application/json");
request.AddHeader("Cookie","GDCAuthTT="+token);
request.AddParameter("application/json","{\r\n    \"report_req\": {\r\n    \"report\": \"/gdc/md/{{WorkspaceID}}/obj/{{Report}}\"\r\n  }\r\n}",ParameterType.RequestBody);

IRestResponse response = client.Execute(request);

执行此操作后,我收到以下错误作为 JSON 响应:

{
    "error": {
        "code": 401,"message": "Authorization required","description": "This server Could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g.,bad password),or your browser doesn't understand how to supply the credentials required","links": {
            "documentation": "https://help.gooddata.com/display/developer/API+Reference#/reference/authentication/log-in"
        }
    }
}

请告诉我如何解决错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)