justeat/ZendeskApiClient

Cannot create anonymous requests from end users

anti-matter opened this issue · 1 comments

When creating a request (i.e. end users create tickets), there is no way to supply the required requester object as described in the Zendesk documentation. The result is that the request fails if the end user is not already known in the system.

Example:

var request = await client.Requests.CreateAsync(new Request
                {
                    Comment = ticketComment,
                    CreatedAt = DateTime.UtcNow,
                    Description = description,
                    Subject = subject,
                    CustomFields = customFields
                });

Here is how I create the client:

private ZendeskClient CreateZendeskClient(string email)
        {
            var httpClient = ServiceLocator.Current.GetInstance<IHttpClientFactory>();
            var options = new ZendeskOptions
            {
                EndpointUri = ZendeskEndpoint,
                Username = email,
                Token = ApiToken
            };

            var optionsWrapper = new OptionsWrapper<ZendeskOptions>(options);

            return new ZendeskClient(new ZendeskApiClientFactory(optionsWrapper, httpClient), _log);
        }

There is the ability to supply a requester_id, but it is unclear how to obtain this id when the end user is new.

What am I missing? Any help would be appreciated.

Thanks in advance!

Hi @anti-matter, I have had a brief look and it doesn't seem like the API currently support anonymous requests for this endpoint. It seems that we need to add the Requester object as an option on the Request object.

I also notice that, even for anonymous requests where auth is not necessary, we still require username/token when instantiating the ZendeskApiClient. We will have a look into having a more natural solution for anonymous requests like this.

Our team has recently taken ownership of this repository so we should get round to it. I have created a TODO card as well.