Skip to content

Error thrown when POST-ing large payload #30

Description

@Windos

I'm trying to use Send-TwitterAccount_UpdateProfileBanner to update my account banner:

$Image = [Convert]::ToBase64String((Get-Content .\TwitterBanner.png -Encoding Byte))
Send-TwitterAccount_UpdateProfileBanner -banner $Image

Naturally, that Image string is HUGE, as I'm trying to send a 1500x500 image (the recommended size for one of these banners) that's 101 KB on disk.

When run, I get back

Get-OAuthParameters : Exception calling "EscapeDataString" with "1" argument(s): "Invalid URI: The Uri string is too long."
At C:\Users\joshuak\Documents\WindowsPowerShell\Modules\PSTwitterAPI\0.0.7\public\Invoke-TwitterAPI.ps1:26 char:24
+     $OAuthParameters = Get-OAuthParameters @OAuthParameters_Params
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-OAuthParameters
 
Invoke-RestMethod : Cannot bind parameter 'Method' to the target. Exception setting "Method": "Cannot convert null to type "Microsoft.PowerShell.Commands.WebRequestMethod" due to enumeration 
values that are not valid. Specify one of the following enumeration values and try again. The possible enumeration values are "Default,Get,Head,Post,Put,Delete,Trace,Options,Merge,Patch"."
At C:\Users\joshuak\Documents\WindowsPowerShell\Modules\PSTwitterAPI\0.0.7\public\Invoke-TwitterAPI.ps1:34 char:23
+     Invoke-RestMethod @RestMethod_Params
+                       ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Invoke-RestMethod], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Looks like the entire image payload is being encoded as part of the URI... which if my understanding of that class is right is capped at 2048 characters? I've tried halving the size of the image, but it's still too long.

I think that shipping this data up as a JSON body on Invoke-RESTMethod would get it up there (I was playing around with this a little, but mucked up the authentication side of things lol)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions