Coder Social home page Coder Social logo

Comments (5)

mkht avatar mkht commented on June 16, 2024 1

This issue is also reproduced in my language, Japanese. (I hadn't noticed this bug until now.)

The is caused by not specifying a charset in the ContentType parameter of the Invoke-RestMethod. if it does not specify, PowerShell seems to implicitly use ISO-8859-1 encoding, which does not support non-Latin characters are not supported.

Try this code. This worked for my environment.

$Token = New-ZoomApiToken -ApiKey $Global:ZoomApiKey -ApiSecret $Global:ZoomApiSecret
$FirstName = 'Vlad'
$LastName = 'Путин'
$Request = [System.UriBuilder]"https://api.zoom.us/v2/users/$user"
$RequestBody = @{
    'first_name'    = $FirstName
    'last_name'     = $LastName
}
$RequestBody = $RequestBody | ConvertTo-Json  
Invoke-RestMethod -Uri $request.Uri -Headers @{'authorization' = ('bearer ' + $Token)} -Body $requestBody -Method PATCH -ContentType 'application/json; charset=utf-8'

Setting the default value of the ContentType parameter in Invoke-ZoomRestMethod to 'application/json; charset=utf-8' may be a solution, but we need to check for any bad side effects.
If you give me a few days, I can provide a pull request, what do you think, @JosephMcEvoy

from pszoom.

IT-BAPBAP avatar IT-BAPBAP commented on June 16, 2024

Заранее благодарю :) (Привет из России)

from pszoom.

JosephMcEvoy avatar JosephMcEvoy commented on June 16, 2024

I am not sure what is wrong. It could have to do with the content-type, which is set in New-ZoomHeaders then passed to Invoke-ZoomRestMethod, which calls Invoke-RestMethod. It could also have to do with how PowerShell and Zoom interpret the characters. Possibly a combination of the two.

@mkht may have some experience with this as he may be using non-Latin characters.

Here is the simplified relevant bits of a code to help you in seeking help outside of Github:

$Token = New-Jwt -Algorithm 'HS256' -type 'JWT' -Issuer $Credentials.ApiKey -SecretKey $Credentials.ApiSecret -ValidforSeconds $ValidforSeconds
$FirstName = 'Vlad'
$LastName = 'Путин'
$Headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$Headers.Add('content-type' , 'application/json')
$Headers.Add('authorization', 'bearer ' + $Token)
$Request = [System.UriBuilder]"https://api.zoom.us/v2/users/$user"
$RequestBody = @{
    'first_name'    = $FirstName
    'last_name'     = $LastName
}
$RequestBody = $RequestBody | ConvertTo-Json  
Invoke-RestMethod -Uri $request.Uri -Headers ([ref]$Headers) -Body $requestBody -Method PATCH

from pszoom.

JosephMcEvoy avatar JosephMcEvoy commented on June 16, 2024

Good analysis and summary. If you have the bandwidth, proceed. Depending on testing, I/we may have to consider adding -ContentType as another parameter for all cmdlets. Thank you for your help, as always.

from pszoom.

IT-BAPBAP avatar IT-BAPBAP commented on June 16, 2024

@mkht , @JosephMcEvoy Thank you very much! Спасибо!))
I can continue to work with my project !!!
For me -ContentType 'application / json; charset = utf-8 'works too))

from pszoom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.