微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决发布请求 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 举报,一经查实,本站将立刻删除。