How to call an ASP.NET WebMethod using PowerShell?
Posted
by Domenic
on Stack Overflow
See other posts from Stack Overflow
or by Domenic
Published on 2010-03-31T16:37:44Z
Indexed on
2010/04/25
18:23 UTC
Read the original article
Hit count: 342
It seems like ASP.NET WebMethods are not "web servicey" enough to work with New-WebServiceProxy
. Or maybe it is, and I haven't figured out how to initialize it?
So instead, I tried doing it manually, like so:
$wc = new-object System.Net.WebClient
$wc.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$url = "http://www.domenicdenicola.com/AboutMe/SleepLog/default.aspx/GetSpans"
$postData = "{`"starting`":`"\/Date(1254121200000)\/`",`"ending`":`"\/Date(1270018800000)\/`"}"
$result = $wc.UploadString($url, $postData)
But this gives me "The remote server returned an error: (500) Internal Server Error." So I must be doing something slightly wrong.
Any ideas on how to call my PageMethod
from PowerShell, and not get an error?
© Stack Overflow or respective owner