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

Attach Invoice With Spaces in Filename Causes 404 Error - Xero.NetStandard.OAuth2 9.2.0 #570

Open
phil000 opened this issue Oct 14, 2024 · 7 comments

Comments

@phil000
Copy link

phil000 commented Oct 14, 2024

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

  • Version Xero.NetStandard.OAuth2 9.2.0

Describe the bug
We have upgraded from Xero.NetStandard.OAuth2 6.0.0 to Xero.NetStandard.OAuth2 9.2.0
When uploading files to attach to an invoice we now get an error code 404, with error content "The resource you're looking for cannot be found"
If we remove the spaces from the filename the upload works correctly.
We have noticed that this error was introduced in Xero.NetStandard.OAuth2 9.0.0
The issue does not occur in 8.1.0.

To Reproduce
Upload a file with spaces.

image

Expected behavior
File attachment with spaces can be uploaded via .NET API.

Copy link

PETOSS-645

Copy link

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

@phil000
Copy link
Author

phil000 commented Oct 28, 2024

We have noted that while the documentation states:
"When the file name includes special characters, the characters should not be encoded unless they're brackets. Brackets must be encoded in order for the call to go through, and all other characters must be unencoded"

If we actually URL path encode the filename the filename with spaces can be uploaded again. (This means replacing spaces with %20, not +)

@DanPatten
Copy link

This just happened to me, I had to use System.Uri.EscapeDataString instead of WebUtility.UrlEncode

@phil000
Copy link
Author

phil000 commented Nov 1, 2024

Yes, FYI the answer is to use System.Uri.EscapeDataString that escapes spaces as "%20"

System.Net.WebUtility.UrlEncode encodes spaces as '+' which does not work.

@DanPatten
Copy link

Can the change be listed in releases as a breaking change? This broke production when our users started getting errors after upgrading and there is no mention of this in the changelog.

@joshsj
Copy link

joshsj commented Nov 1, 2024

Yes, FYI the answer is to use System.Uri.EscapeDataString that escapes spaces as "%20"

System.Net.WebUtility.UrlEncode encodes spaces as '+' which does not work.

+1, this is what RestSharp is using (and therefore what this SDK was using up to 9.x.x).

For reference:

This raises the question of whether compatibility with massive URLs should also be preserved as part of the fix? Seems like the sensible option given we can simply adopt RestSharp's method - there's a simplified version in the codebase already.

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

3 participants