Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xero.NetStandard.OAuth2 9.1.0 CreateInvoiceAttachmentByFileNameAsync fails #542

Open
DaithiBradley opened this issue Sep 3, 2024 · 5 comments

Comments

@DaithiBradley
Copy link

SDK you're using (please complete the following information):

  • Version [9.1.0]

Describe the bug
When attempting to update a file to an invoice in version 9.1 an exception is returned.

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: T. Path '', line 0, position 0. at bool Newtonsoft.Json.JsonTextReader.ParseValue() at bool Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, bool hasConverter) at object Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, bool checkAdditionalContent) at object Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at object Newtonsoft.Json.JsonConvert.DeserializeObject(string value, Type type, JsonSerializerSettings settings) at T Newtonsoft.Json.JsonConvert.DeserializeObject<T>(string value, JsonSerializerSettings settings)

The response body from developer.xero.com for the API call shows:

The resource you're looking for cannot be found

When the package is downgraded from nuget package 9.1.0 to 8.1.0 the call works as expected with the same code.

Expected behavior
An existing invoice has a file attached to it.

Screenshots
None

Additional context
Nil

Copy link

github-actions bot commented Sep 3, 2024

PETOSS-567

Copy link

github-actions bot commented Sep 3, 2024

Thanks for raising an issue, a ticket has been created to track your request

@Plasma
Copy link

Plasma commented Jan 6, 2025

I can also reproduce this issue

@Plasma
Copy link

Plasma commented Jan 6, 2025

@DaithiBradley I've got a workaround you can use, likely due to having a space or other unescaped value in the URL path due to the Filename parameter.

If you're using a Filename such as Example - With Spaces.pdf this is not URL path encoded (eg to Example%20-%20With%20Spaces.pdf) and so the requested URL becomes invalid when the SDK attempts to POST the file. Specifying a filename without spaces succeeds. Previous SDK encoded this parameter automatically.

Suggested solution is for the SDK to encode this parameter using Uri.EscapeDataString(filenameToUse) and in the interim you can do this yourself before passing the filename parameter to the SDK method.

See https://developer.xero.com/documentation/api/accounting/attachments

@Plasma
Copy link

Plasma commented Jan 7, 2025

Found this is mentioned in #570 (linking these tickets)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants