justeat/ZendeskApiClient

Error when creating attachment

JesperNJessen opened this issue · 1 comments

I'm getting an error when I try to use the AttachmentsResource.UploadAsync method.

Error message is "Status code retrieved was 422 and not a 201 as expected".

My code:

var zendeskOptions = new ZendeskOptions
{
    EndpointUri = "https://{mycompany}.zendesk.com",
    Username = "{myemail]",
    Token = "{mytoken}"
};

var zendeskOptionsWrapper = new OptionsWrapper<ZendeskOptions>(zendeskOptions);
var client = new ZendeskApiClient(zendeskOptionsWrapper);

_attachmentsResource = new AttachmentsResource(client, NullLogger.Instance);

...


var byteArray = System.IO.File.ReadAllBytes(filename);
var stream = new MemoryStream(byteArray);

var upload = await _attachmentsResource.UploadAsync(shortfilename, stream); //this line fails

Is there something I'm missing?
I went through the tests, but it looks to me like I'm doing the exact same thing.

NuGet package version installed is "3.1.0-alpha-374"

Hi @JesperNJessen, I have added a TODO card to look into this. Our team will prioritise this as part of our usual work flow, can't promise when we will get round to it. In the meantime please do let me know if this is still an issue for you - I am conscious the issue is 4 years old.