Skip to content

Conversation

stawr93
Copy link

@stawr93 stawr93 commented Oct 29, 2018

If your queue (or exchange) name contains some space chars, any operations you want to do with it will end up with an error like this:

Invoke-RestMethod : {"error":"Object Not Found","reason":"Not Found"}
At C:\Program Files\WindowsPowerShell\Modules\RabbitMQTools\1.5\Public\Remove-RabbitMQQueue.ps1:94 char:17
+ ...             $result = Invoke-RestMethod $url -Credential $Credentials ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Invoke-RestMethod : {"error":"Object Not Found","reason":"Not Found"}
At C:\Program Files\WindowsPowerShell\Modules\RabbitMQTools\1.5\Public\Remove-RabbitMQQueue.ps1:94 char:17
+ ...             $result = Invoke-RestMethod $url -Credential $Credentials ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

This caused by incorrect encoding url:
RMQ expects smth like:
http://localhost:15672/api/queues/%2F/API%2C%20API

But actual url generated by script is:
http://localhost:15672/api/queues/%2f/API%2c+API

@RamblingCookieMonster
Copy link
Owner

Hiyo!

Sorry for the wait, finally had time to go through PRs : ) This works for me if no one has any issues with it - Are there any cases where the inverse occurs? i.e. a string going through [System.Uri]::EscapeDataString producing something this API doesn't like?

Barring cases like that, I'm happy to merge this! Will plan on merging it in a week or two if I don't hear of any issues - can always revert, or add a switch to allow swapping those methods as needed.

Cheers!

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

Successfully merging this pull request may close these issues.

2 participants