mkellerman / PSTwitterAPI

PSTwitterAPI - a PowerShell module for the Twitter API
https://mkellerman.github.io/Introducing_PSTwitterAPI/
45 stars 13 forks source link

Error calling Send-TwitterDirectMessages_EventsNew: Bad Authentication Data #48

Open chinhdo opened 3 years ago

chinhdo commented 3 years ago

Any idea why I am getting this error calling Send-TwitterDirectMessages_EventsNew?

Code:

$TwitterUser = Get-TwitterUsers_Lookup -screen_name 'chinhdo'
$Event = Send-TwitterDirectMessages_EventsNew -recipient_id $TwitterUser.Id -text "Hello !!"

The Get-TwitterUsers_Lookup method works fine. But the Send-TwitterDirectMessages_EventsNew errored out with the below. I did configure the app permissions to allow Read + Write + Direct Messages.

Invoke-RestMethod : {"errors":[{"code":215,"message":"Bad Authentication data."}]}
At C:\Program Files\WindowsPowerShell\Modules\PSTwitterAPI\0.0.8\public\Invoke-TwitterAPI.ps1:34 char:5
+     Invoke-RestMethod @RestMethod_Params
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExceptio  
   n
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
WARNING: Throttling for -1626964553.70296 seconds.
Start-Sleep : Cannot validate argument on parameter 'Seconds'. The -1626964554 argument is less than the minimum allowed 
range of 0. Supply an argument that is greater than or equal to 0 and then try the command again.
At C:\Program Files\WindowsPowerShell\Modules\PSTwitterAPI\0.0.8\public\Get-TwitterOAuthSettings.ps1:33 char:38
+                 Start-Sleep -Seconds $SleepSeconds
+                                      ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Start-Sleep], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.StartSleepCommand

Thanks

mkellerman commented 3 years ago

All APIs have their own script, automatically generated from the documentation from Twitter. But unfortunately, not all the functions/methods/APIs have been fully tested it.

I suspect this one hasn't been tested.