Solved

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

Posted on 2014-02-26
1
2,881 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
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…

732 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