Getting headends without specifying a postal code

Getting headends without specifying a postal code

Postby cwchapma » Sun Mar 31, 2013 1:20 pm

When I try to get headends without specifying a postal code, It tries to send me a text file instead of just the text (which is what happens when I specify a postal code).

Code: Select all
{"randhash":"xxxx","object":"headends","action":"get","api":20130224}


Beyond that, the array it sends back in the text file is empty:

Code: Select all
{"response":"OK","code":200,"serverID":"AWS-web.1","datetime":"2013-03-31T20:10:40Z","data":[]}


I believe I currently have 2 headends associated with my account.

Any ideas?

Thanks in advance,
Clint
cwchapma
 
Posts: 42
Joined: Fri Mar 29, 2013 8:32 am

Re: Getting headends without specifying a postal code

Postby Slugger » Mon Apr 01, 2013 11:52 am

I believe you need to add a request: null to your submission.

Code: Select all
{"randhash":"xxxx","object":"headends","action":"get","api":20130224,"request":null}


If you're looking for another client implementation to see how other clients are submitting things, my Java client isn't a bad place to look. Even if you don't know Java, it should be relatively easy to read, especially if you're writing C#.
Slugger
 
Posts: 77
Joined: Sun Sep 18, 2011 1:22 pm

Re: Getting headends without specifying a postal code

Postby cwchapma » Thu Apr 04, 2013 1:19 pm

Slugger, thanks for the suggestion but I'm getting the same result with or without the "request":null.

I think I know what my problem is. I was assuming my settings from the old interface were transferred to the new system. In hindsight that seems like a silly assumption.

Doh!
cwchapma
 
Posts: 42
Joined: Fri Mar 29, 2013 8:32 am

Re: Getting headends without specifying a postal code

Postby cwchapma » Sat Apr 06, 2013 4:06 pm

Okay, it appears there is a difference depending on whether you specify "request":null or not. "request":null is required to get the list of configured headends. Without it, it gives a list of all possible headends for a certain region? It looks like the wiki needs to be updated. Right now it says:

If the randhash is included in the request, the server will reply with only the headends that the user has configured:

Send:
{"randhash":"{randhash}","object":"headends","action":"get","api":20130224}


There's nothing about whether or not you specify "request":null. I'd rather that having "request" not included and "request":null not give different results because it with the json library I'm using they essentially mean the same thing. Again, that's just a preference. It's not hard to work around that but it could be simpler.

Slugger, thanks for the tip. Don't think I ever would have figured that out otherwise.

Clint
cwchapma
 
Posts: 42
Joined: Fri Mar 29, 2013 8:32 am

Re: Getting headends without specifying a postal code

Postby rkulagow » Mon Apr 15, 2013 11:17 am

OK, the issue with needing to send a request:null may be a side effect of something else. I've added some debugging on the beta server, so please try again and let me know the time that you made the hit so that I can check the logs.

Try the get->headends with and without the request please.
rkulagow
SD Staff
 
Posts: 915
Joined: Tue Aug 14, 2007 3:15 pm

Re: Getting headends without specifying a postal code

Postby cwchapma » Sat Apr 20, 2013 10:49 am

Sorry posted this a while ago on the wrong thread:

When I make the request:

Code: Select all
{"randhash":"-----","request":null,"object":"headends","action":"get","api":20130311}


The beta server seems to be trying to send a binary attachment (see the header) even though the content is json

Code: Select all
HTTP/1.1 200 OK
Date: Tue, 16 Apr 2013 02:35:15 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.6
Content-Description: File Transfer
Content-Disposition: attachment; filename=headendUBjL5Q
Content-Transfer-Encoding: binary
Expires: 0
Cache-Control: must-revalidate
Pragma: public
Content-Length: 119
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/octet-stream

{"response":"ERROR","code":403,"datetime":"2013-04-16T02:35:15Z","message":"No headends configured for this account."}


Without "request":null

Code: Select all
{"randhash":"d818e3988fcd790991b9b00b6a4355d5","object":"headends","action":"get","api":20130311}


I get all the headends?

Code: Select all
HTTP/1.1 200 OK
Date: Tue, 16 Apr 2013 02:42:46 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.6
Content-Description: File Transfer
Content-Disposition: attachment; filename=headendvJ5EEH
Content-Transfer-Encoding: binary
Expires: 0
Cache-Control: must-revalidate
Pragma: public
Content-Length: 679
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/octet-stream

{"response":"OK","code":200,"serverID":"AWS-micro.1","datetime":"2013-04-16T02:42:46Z","data":[{"headend":"0005986","name":"Shaw Direct","location":"Canada (East) Advanced"},{"headend":"0005995","name":"Shaw Direct","location":"Canada (East) Classic"},{"headend":"0009995","name":"Shaw Direct","location":"Canada (West) Advanced"},{"headend":"0009999","name":"Shaw Direct","location":"Canada (West) Classic"},{"headend":"0005993","name":"Bell TV","location":"Canada (East)"},{"headend":"0008999","name":"Bell TV","location":"Canada (West)"},{"headend":"FTA","name":"Free-to-air satellite","location":"Global"},{"headend":"norequest","name":"Antenna","location":"Over-the-air"}]}


I didn't notice the fact it was trying to return an attachment until I tried using the request.php form and instead of showing me the result, it downloads a file. My client ignores the header.

Hope that helps,
Clint
cwchapma
 
Posts: 42
Joined: Fri Mar 29, 2013 8:32 am


Return to Developer

Who is online

Users browsing this forum: No registered users and 1 guest