Solved

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

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

23 Experts available now in Live!

Get 1:1 Help Now