Solved

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

Posted on 2014-02-26
1
2,398 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
1 Comment
 
LVL 39

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Set OWA language and time zone in Exchange for individuals, all users or per database.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now