Page 1 of 1

Getting 404 error calling Status

Posted: Sun Aug 06, 2017 5:03 am
by mskoglund
Using C# and .NET I am getting a 404 return code from the "status" interface using the following code:

Code: Select all

var httpWebRequest = (HttpWebRequest)WebRequest.Create("");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.UserAgent = SDData.userAgent;
httpWebRequest.Headers.Add("token", SDData.token.token);

var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
I have successfully called "token" and I think I have added the value to the Header.

I am experienced in .NET but this is my first time calling a JSON interface.

Any help would be appreciated, thanks.

Re: Getting 404 error calling Status

Posted: Wed Sep 13, 2017 6:54 am
by jcole998
Hello. I see that no one replied to your question. May I guess that you solved your problem? If so, I could use your help.

I am trying to use Windows Powershell to access SD schedules but without success. I am new to Powershell but the language and syntax closely resembles C#. Could you send a C# code snippet that gets the token? I've had no success getting the call to work. The website return code is always "400 Bad input."

Here's what I've tried:

$sdUID = 'abcdef'
$sdPW = Get-StringHash -String "123456" -HashName "SHA1"
$sdPW = $sdPW.ToLower()
$jhsdLogin = @{"username"= $sdUID; "password"= $sdPW} | ConvertTo-Json
$sdUAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer
$sdToken = Invoke-WebRequest -Uri -UseBasicParsing -Method Post -Body $jhsdLogin -UserAgent $sdUAgent -ContentType "application/json;charset=UTF-8" -Debug

Hope you can help or maybe lead me to somewhere more appropriate.