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

Problem with non english Characters when getting Objects #43

Open
RudolfAchter opened this issue Sep 14, 2020 · 4 comments
Open

Problem with non english Characters when getting Objects #43

RudolfAchter opened this issue Sep 14, 2020 · 4 comments

Comments

@RudolfAchter
Copy link

For this one i have no fix for now.

There are also issues whent getting Objects with german umlauts

image

@AnythingOverIP
Copy link

I have the same issue when trying to update with accents
Using:
foreach ($site in $sites) { $values= [PScustomObject]@{ name = $site.site_EngNumber status = $site.site_status region = $site.site_region tenant = $site.site_tenant facility = $site.site_name description = $site.site_description physical_address = $site.site_address latitude = $site.site_latitude longitude = $site.site_longitude comments = $site.site_comments tags = $site.site_tags } $updates = $values | remove-Null write-host "[INFO] Atempting an update with those values:" $updates write-host "[INFO] Result: " if ($allsites.name -contains $site.site_engNumber) { $site_data = Get-nbSite -Query @{name=$site.site_EngNumber} Set-nbSite -id $site_data.id -Object $updates -Patch } else { write-host "[WARNING] Engineering site number not found in Netbox." -background red write-host "----------------------------------------------------------------------" } }

I get the following output:
[INFO] Atempting an update with those values:
name : R####
status : active
facility : R#### Édifice (redacted)
physical_address : redacted
latitude : ##.#####
longitude : -##.#####
tags : {3}

[INFO] Result:

Invoke-nbApi : {"detail":"JSON parse error - 'utf-8' codec can't decode byte 0xc9 in position 234: invalid continuation byte"}
At C:\Users\redacted\Documents\WindowsPowerShell\Modules\powerbox\2.3.5\Public\Set-nbObject.ps1:127 char:16
+ ...      return Invoke-nbApi -Resource $Resource/$id -HttpVerb Patch -Bod ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-nbApi], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Invoke-nbApi
Invoke-nbApi : {"detail":"JSON parse error - 'utf-8' codec can't decode byte 0xc9 in position 234: invalid continuation byte"}
At C:\Users\redacted\Documents\WindowsPowerShell\Modules\powerbox\2.3.5\Public\Set-nbObject.ps1:129 char:12
+     return Invoke-nbApi -Resource $Resource/$id -HttpVerb Put -Body ( ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-nbApi], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Invoke-nbApi

@AnythingOverIP
Copy link

I was able to fix updates by changing line #121 of Invoke-nb-Api.ps1 from ContentType = 'application/json' to
ContentType = 'application/json; charset=utf-8'
That fixes the uploads and accents are well represented when looking at the WebUI.

That being said, I was not able to find the encoding for the gets. I still get gibberish characters when loading information that contains UTF-8 caracters... :| Scheiße!

@AnythingOverIP
Copy link

@RudolfAchter , I was able to get proper UTF8 characters in console using PowerShell 7.0.4

Previously, I was using powershell 5.1.19041.610 and it seems that 5.1 has some issues rendering proper character set in terminal. a Workaround would have been to output to file and reload to terminal forcing UTF-8 but it seems like a stretch to me...

@RudolfAchter
Copy link
Author

@RudolfAchter , I was able to get proper UTF8 characters in console using PowerShell 7.0.4

Previously, I was using powershell 5.1.19041.610 and it seems that 5.1 has some issues rendering proper character set in terminal. a Workaround would have been to output to file and reload to terminal forcing UTF-8 but it seems like a stretch to me...

@thefreakquency . I almost forgot about this issue :-) . I recently had no time to work with my Netbox / Powerbox Instance. But Thank you for your suggestions to fix this. I will try it in my installation

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