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

Encoding error using Get-CosmosDbDocument #282

Closed
runeemde opened this issue Apr 3, 2019 · 10 comments · Fixed by #283
Closed

Encoding error using Get-CosmosDbDocument #282

runeemde opened this issue Apr 3, 2019 · 10 comments · Fixed by #283
Assignees
Labels
needs investigation The issue needs to be investigated by the maintainers or/and the community.

Comments

@runeemde
Copy link

runeemde commented Apr 3, 2019

Hi,

I'm using special characters and have no problem saving them to the cosmos database using UTF-8 encoding.

New-CosmosDbDocument -Context $cosmosDbContext -Database $databaseId -CollectionId $collectionId -DocumentBody $documentStr -Encoding UTF-8

When the data are retrieved again the data is not UTF-8 any more.

Get-CosmosDbDocument -Context $cosmosDbContext -Database $databaseId -CollectionId $collectionId -Id $documentId

@PlagueHO PlagueHO added the needs investigation The issue needs to be investigated by the maintainers or/and the community. label Apr 3, 2019
@PlagueHO
Copy link
Owner

PlagueHO commented Apr 3, 2019

Hi @runeemde - thank you for raising this. I thought I had tests covering this, but I only have them checking if the ID is UTF-8 (https://github.com/PlagueHO/CosmosDB/blob/dev/test/Integration/CosmosDB.integration.Tests.ps1#L1073) - it doesn't check the body. Are you able to paste a sample payload here (with no sensitive data) and I'll use it as a test case to prepare a fix against. I'll take a look at this tonight.

@PlagueHO PlagueHO self-assigned this Apr 3, 2019
@runeemde
Copy link
Author

runeemde commented Apr 3, 2019

Hi @PlagueHO, Thank you for the quick response.

The picture below shows my cosmos document with a property data "sdsføæå"
image

And when I'm fetching the data I looks like this
image

@PlagueHO
Copy link
Owner

PlagueHO commented Apr 3, 2019

Awesome! Thanks @runeemde. I'll take a look tonight and get it sorted for you.

@PlagueHO
Copy link
Owner

PlagueHO commented Apr 4, 2019

Hi @runeemde - I've found and fixed the problem. It was actually caused by a really old PowerShell issue: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/13685217-invoke-restmethod-and-invoke-webrequest-encoding-b

I've just got a bit of clean up/refactoring to do to correct it, but I'm aiming to have this out tomorrow for you.

@runeemde
Copy link
Author

runeemde commented Apr 4, 2019

Thanks for quick response @PlagueHO, looking forward to the update!

@PlagueHO
Copy link
Owner

PlagueHO commented Apr 4, 2019

I have submitted a PR to fix this and I'll merge it tomorrow if all the tests pass:
#283

PlagueHO added a commit that referenced this issue Apr 5, 2019
Fix Encoding bug in Get-CosmosDbDocument - Fixes #282
@PlagueHO
Copy link
Owner

PlagueHO commented Apr 5, 2019

Just releasing this now. Should be out in a few hours.

@PlagueHO
Copy link
Owner

PlagueHO commented Apr 5, 2019

It has been released to the PS Gallery: https://www.powershellgallery.com/packages/CosmosDB/3.2.3.359

@runeemde
Copy link
Author

runeemde commented Apr 5, 2019

Thank you for your quick response, I've testet it with my issue and everything worked great.

Thanks a million, have a great weekend!

@PlagueHO
Copy link
Owner

PlagueHO commented Apr 5, 2019

My pleasure @runeemde - glad to help 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation The issue needs to be investigated by the maintainers or/and the community.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants