404 error getting token on json - 2nd try

Use this forum to discuss issues related to the SD-JSON service.

404 error getting token on json - 2nd try

Postby dalepres » Fri Jan 11, 2019 6:51 pm

I posted this once and, because it's my first post, it was held for moderation. Two weeks later and it's not visible yet and I'm still having the issue. Hopefully this one can get posted and/or attention/answered.

I'm starting development on a new application. I signed up for schedulesdirect, extended it for a year, have the receipts, etc. I am trying to start with a simple call to https://json.schedulesdirect.org/20141201/token in order to get a token. I have added my user ID and sha1-encoded password, as instructed in the documentation, but when I call the web service I get a 404 error in response. I tried my user ID and sha1-encoded password and I also tried it with my email address and encoded password and I tried it without having them as well - clicking the link directly from the documentation on Github. Always, I get the 404.

Other service methods I call return a message that the token is missing so I know I'm getting to the site. Other methods that don't require a token actually work. The only problem, at least so far, is getting a token.

Is there something missing in the documentation or something I missed in the documentation? What do I need to do to get a token?
dalepres
 
Posts: 4
Joined: Sat Dec 08, 2018 8:01 pm

Re: 404 error getting token on json - 2nd try

Postby karamike » Mon Jan 14, 2019 5:04 pm

The API call to obtain a token is a POST request (Clicking on a link in a browser creates a GET request - which might be the reason for the 404).

Username and the hashed password have be provided in the body in JSON format.

Code: Select all
{'username': '********', 'password': '********'}


It might be necessary that the Content-Type HTTP header has to be set to "application/json;charset=UTF-8" to indicate a JSON payload. (The Python requests library I'm using adds it automatically - so I'm not sure).

The answer to the POST request is also a JSON message containing (among others) the token:

Code: Select all
        {
            "code": 0,
            "message": "OK",
            "serverID": "20141201.web.X",
            "datetime": "2019-01-02T20:02:15Z",
            "token": "12345678901234567890123456789020"
        }


When doing API calls that need a token it has to be put into a HTTP header field named "Token".

I hope that helps.
karamike
 
Posts: 4
Joined: Wed Jan 02, 2019 1:15 pm

Re: 404 error getting token on json - 2nd try

Postby rkulagow » Mon Jan 14, 2019 8:14 pm

There was also some code in this github repository which (although old), should still allow you to get a sense of how things work.

https://github.com/SchedulesDirect/mfdb ... I-20141201

In addition the XMLTV project has at least two grabbers for the JSON service, so you can look at other code.

If you're still having issues, then send me an email, and I will turn on server-side debugging for your account.
rkulagow
SD Staff
 
Posts: 915
Joined: Tue Aug 14, 2007 3:15 pm

Re: 404 error getting token on json - 2nd try

Postby dalepres » Wed Jan 16, 2019 7:22 am

Karamike, it turns out Postman defaults to GET. I switched it to Post and now it works. Thanks for the help.

Dale
dalepres
 
Posts: 4
Joined: Sat Dec 08, 2018 8:01 pm


Return to SD-JSON service

Who is online

Users browsing this forum: No registered users and 3 guests