justeat/ZendeskApiClient

Problem with ResourceUri

Closed this issue · 1 comments

Hello

I am trying to use this api which seems very useful. I am currently using version 3.1.0-alpha-339. My issue is that whenever I try to use the ZendeskClient I get the following error in my browser:
"No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5001' is therefore not allowed access. The response had HTTP status code 500."

I am creating my client in the following manner:

private IZendeskClient GetZendeskClient(string email)
{
    var zendeskOptions = new ZendeskOptions
    {
        EndpointUri = "https://SomeName.zendesk.com/",
        Username = email,
        Token = ZENDESK_APIKEY
    };

    var zendeskOptionsWrapper = new OptionsWrapper<ZendeskOptions>(zendeskOptions);
    return new ZendeskClient(new ZendeskApiClient(zendeskOptionsWrapper));
}      

And making a simple request:
var tickets = await client.Tickets.ListAsync();

It is the above request that results in the error. Now I have looked around the code and found your Resource classes where the uri's for the http requests are created. I have then tried and make the http calls manually without your api and gotten the same error when using the uri's you are using, such as the ResourceUri found in TicketsResource: private const string ResourceUri = "api/v2/tickets"; Thus calling the Zendesk api with a uri on the form: https://SomeName.zendesk.com/api/v2/tickets

After some searching around different forums I found that a http call to Zendesk must have the format such as: https://SomeName.zendesk.com/api/v2/tickets.json

Using this request I am able to get a positive response from the Zendesk v2 api. It seems that all your uri's are missing .json. I do not know if this api is working for others I however am having these issuses so if others know how to make it work or what I am missing when setting up the client the I would be happy to hear from you.

When I called the api with Fiddler, /api/v2/tickets.json and /api/v2/tickets had the same response.
Have you tried the same call without .json on Fiddler or Postman?