最近搜索


没有最近搜索

Trying to create api via c#



已于 2025年4月22日 发布

I'm attempting to create a class in my application that will integrate with Zendesk.  However when I'm attempting to create a ticket I keep getting an error…
The remote server returned an error: (401) Unauthorized.Error content: {"error":"Couldn't authenticate you"} 

 

This is the code I'm using to create the api

            public ZendeskHelper()
           {
               string subdomain = ConfigurationManager.AppSettings["ZendeskSubdomain"];
               string email = ConfigurationManager.AppSettings["ZendeskEmail"];
               string apiToken = ConfigurationManager.AppSettings["ZendeskApiToken"];
               // Ensure credentials are not null or empty
               if (string.IsNullOrEmpty(subdomain) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(apiToken))
               {
                   throw new InvalidOperationException("Zendesk API credentials are not properly configured in Web.config.");
               }
               
               api = new ZendeskApi($"https://{subdomain}.zendesk.com/api/v2/users/me.json", email, apiToken);
           }

 

How do I resolve this?


0

1

1 条评论

      Hi Eduardo, 

      Does the string in your `email` variable include the suffix ‘/token’? Example:

      jdoe@example.com/token’

      See https://developer.zendesk.com/api-reference/introduction/security-and-auth/#api-token.

      0


      登录以发表评论。

      找不到所需的内容?

      新建帖子