NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Support Windows v
« Previous 1 … 91 92 93 94 95 … 102 Next »
Web API Error

 
  • 0 Vote(s) - 0 Average
Web API Error
jcole998
Offline

Posting Freak

New York, USA
Posts: 865
Threads: 186
Joined: Jun 2015
#1
2020-02-13, 02:32 PM
I rely quite a bit on the ability to submit commands via the web API. I'm testing V5 for compatibility with the commands that I use to set new recordings in V4. The command was submitted and resulted in the indicated error. Just before I submitted this thread, I tried it again and this time is worked! I can't seem to pin down what was different between the two trials.

Can you suggest what's going on?

- Receiving this error from the submitted command:
11:36:34 Command: http://localhost:8867/services/service?m..._padding=3
11:36:34 Program "A Beautiful Place to Die: A Martha's Vineyard Mystery" NOT scheduled: Error code 8, Invalid Session.


Attached Files
.zip   logsV5-20200213-0927.zip (Size: 676.51 KB / Downloads: 1)
Later...JohnC

System Status: Humming nicely!  Smile
Desktop: Intel DX38BT MB - Intel Q9650 3GHz Quad - NVIDIA GeForce GTX 1050 Ti Graphics
Software: Win 10 Pro(Build 1909) - NextPVR - WinTV8
Video: Verizon FiOS - Hauppauge DCR-3250 - Hauppauge 1512 HDPVR2
RaspberryPi 4 Raspbian and FLIRC
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 53,109
Threads: 957
Joined: May 2006
#2
2020-02-13, 02:42 PM
You seem to be forgetting the sid that we already discussed https://forums.nextpvr.com/showthread.ph...#pid526152

Also remember there is a developer sub forum to help keep these posts organized better.

Martin
jcole998
Offline

Posting Freak

New York, USA
Posts: 865
Threads: 186
Joined: Jun 2015
#3
2020-02-13, 05:11 PM
You're right, Martin. I looked at that thread again(broken links in #7 and #20) and I will try the NScriptHelper items that sub suggested.

JC
jcole998
Offline

Posting Freak

New York, USA
Posts: 865
Threads: 186
Joined: Jun 2015
#4
2020-02-16, 05:21 PM
Still trying to get info from V5 through a login session with pincode "0000" from the example shown in the NextPVR post "Simulate old CommandLineOptions."

After getting a successful response for the session.initiate request, I tried to establish a V5 web session using the web API:

session.initiate response
stat sid                              salt                               
---- ---                              ----                               
ok  90e4bce9be9c473ea03ea84d2d21ab4b cbf08981-1720-4750-a44d-c8f5fd4c946e

session.login command:

http://localhost:8867/service?method=ses...63ED235D90

Response was:

StatusCode        : 200
StatusDescription : OK
Content          : <?xml version="1.0" encoding="utf-8" ?>
                    <rsp stat="fail">
                      <err code="1" msg="Login Failed" />
                    </rsp>
                   
RawContent        : HTTP/1.1 200 OK
                    Content-Length: 107
                    Content-Type: text/xml
                    Date: Sun, 16 Feb 2020 16:39:45 GMT
                    Server: Kestrel
                   
                    <?xml version="1.0" encoding="utf-8" ?>
                    <rsp stat="fail">
                      <err code="1" msg="L...
Forms            : {}
Headers          : {[Content-Length, 107], [Content-Type, text/xml], [Date, Sun, 16 Feb 2020
                    16:39:45 GMT], [Server, Kestrel]}
Images            : {}
InputFields      : {}
Links            : {}
ParsedHtml        : System.__ComObject
RawContentLength  : 107


The &md5 parameter was an MD5 hash of:

$md5In = (":" + $HashPin.Hash + ":" + $xmlRespInit.rsp.salt)
$md5In = ":4A7D1ED414474E4033AC29CCB8653D9B:cbf08981-1720-4750-a44d-c8f5fd4c946e"

I checked the MD5 codes against an online MD5 hash generator and they matched.

I am quite unfamiliar with V5 logs so I'm hoping the logs can tell you what's causing the failure.

Thanks.


Attached Files
.zip   logsV5-20200216-1142.zip (Size: 647.21 KB / Downloads: 1)
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,789
Threads: 769
Joined: Nov 2003
#5
2020-02-16, 05:29 PM
From memory, I think your pin hash needs to be lower case.
jcole998
Offline

Posting Freak

New York, USA
Posts: 865
Threads: 186
Joined: Jun 2015
#6
2020-02-16, 06:23 PM
No joy, sub. Where do I look in the log file?
Later...JohnC

System Status: Humming nicely!  Smile
Desktop: Intel DX38BT MB - Intel Q9650 3GHz Quad - NVIDIA GeForce GTX 1050 Ti Graphics
Software: Win 10 Pro(Build 1909) - NextPVR - WinTV8
Video: Verizon FiOS - Hauppauge DCR-3250 - Hauppauge 1512 HDPVR2
RaspberryPi 4 Raspbian and FLIRC
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,789
Threads: 769
Joined: Nov 2003
#7
2020-02-16, 06:29 PM
This is a bit of C# code that successfully logs in:

Code:
WebClient client = new WebClient();
var initiateXML = client.DownloadString(server + "/service?method=session.initiate&ver=1.0&device=scripthelper");                

XmlDocument doc = new XmlDocument();
doc.LoadXml(initiateXML);

string tempSID = doc.SelectSingleNode("/rsp/sid").InnerText;
string tempSalt = doc.SelectSingleNode("/rsp/salt").InnerText;

MD5CryptoServiceProvider md5Provider = new MD5CryptoServiceProvider();
byte []pinData = md5Provider.ComputeHash(Encoding.ASCII.GetBytes(pin));
string pinMD5 = BitConverter.ToString(pinData).Replace("-", "");

string combined = ":" + pinMD5.ToLower() + ":" + tempSalt;
                
byte[] data = md5Provider.ComputeHash(Encoding.ASCII.GetBytes(combined));
string expectedMD5 = BitConverter.ToString(data).Replace("-", "");

var loginXML = client.DownloadString(server + "/service?method=session.login&sid=" + tempSID + "&md5=" + expectedMD5);
if (loginXML.Contains("<rsp stat=\"ok\">"))
{
    sid = tempSID;
}
else
{
    Logger.Debug("Unable to login");
}
jcole998
Offline

Posting Freak

New York, USA
Posts: 865
Threads: 186
Joined: Jun 2015
#8
2020-02-16, 06:52 PM
Thanks, sub. I'll try again.
jcole998
Offline

Posting Freak

New York, USA
Posts: 865
Threads: 186
Joined: Jun 2015
#9
2020-02-18, 04:33 PM
I'm finally having success! Big Grin Thanks for your patience. I can now ask for pending recordings and schedule new ones. The door is open!

May I ask a few more questions...

For how long does a session last?
Should I initiate a new session and new login with each series of requests?
Can I test if a session(SID) is still usable?

Thanks, again.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,789
Threads: 769
Joined: Nov 2003
#10
2020-02-18, 05:00 PM
From memory it'll last a couple of hours since the last call, unless you restart the recording service.

Realistically, I'd just login at the time you need to make any requests of the server, rather than trying to remember the side and use it over a period of time.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (2): 1 2 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  Windows could not start the NextPVR Service service on Local Computer Error 193:0xc1 Jimmyts100 7 5,777 2025-06-18, 06:26 PM
Last Post: jcole998
  error: No tuner was available for the requested channel jzk 3 338 2025-04-19, 03:30 PM
Last Post: mvallevand
  Video image error on software kellanphil 1 255 2025-02-28, 04:11 AM
Last Post: sub
  EPG Script Error? RedDevilJoe 4 401 2025-02-01, 01:16 AM
Last Post: RedDevilJoe
  Error 400 wakecars067 16 2,210 2024-09-15, 11:59 PM
Last Post: mvallevand
  Error at 58 minutes playback Offroad 4 674 2024-06-01, 01:17 PM
Last Post: Offroad
  Files Still Open Error fccgrant 14 1,638 2024-03-29, 06:53 PM
Last Post: fccgrant
  Application Error crash apuftw 8 2,714 2024-01-25, 09:30 PM
Last Post: sub
  Failure to wake and powercfg error nextmel 6 1,261 2024-01-05, 08:19 PM
Last Post: gEd
  IsComplete(): An error occurred while parsing EntityName. Line X, position Y. djenson 6 1,119 2023-08-19, 10:16 PM
Last Post: mvallevand

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode