Trying to create api via c#



Data ultimo post: 22 apr 2025

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 commento

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


Accedi per lasciare un commento.

Non hai trovato quello che cerchi?

Nuovo post