Solved

Invoke-WebRequest : This operation is not supported for a relative URI.

Posted on 2014-02-26
1
2,826 Views
Last Modified: 2014-02-26
With a lot of help from experts the following code is working fine:-
$postParams = "username=me&moredata=qwerty66"
$test = Invoke-WebRequest -Uri http://localhost/TestForm.php -Method POST -Body $postParams -Proxy '172.16.8.11:3128'

write-host $test

Open in new window


However if I put an external domain in:-
$postParams = "username=me&moredata=qwerty66"
$test = Invoke-WebRequest -Uri http://test.tonycross.me.uk/testForm.php -Method POST -Body $postParams -Proxy '172.16.8.11:3128'

write-host $test

Open in new window


I get:-

Invoke-WebRequest : This operation is not supported for a relative URI.
At D:\Users\TCross\Desktop\Post Data - Invoke.ps1:5 char:9
+ $test = Invoke-WebRequest -Uri "http://test.tonycross.me.uk/testForm.php" -Metho ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-WebRequest], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

What its supposed to do is just post some data to a webform and get a response from the server.

Any ideas what Im doing wrong?

Thank you
0
Comment
Question by:tonelm54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 39890006
This really isn't a command I've used before so the help I can provide is probably limited, but since no one else had replied yet...

The command worked for me if I removed the -proxy parameter.  So I'm thinking the problem must be there.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Set OWA language and time zone in Exchange for individuals, all users or per database.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question