Project

General

Profile

Accessing TVHeadend through API

Added by Je Yen Chen over 4 years ago

curl --data conf={"enabled":true,"start":1581612630,"stop":1581619830,"channel":"0f25ed63f4f056f18ad25df39c1dda98","title":{"M Countdown"},"comment":"Test MCD","start_extra":4,"stop_extra":4,"pri":0,"config_name":""}' "http://localhost:9981/api/dvr/entry/create" 

This is the code that I'm following based on API documentation for TVHeadend and I get a return of 400 Bad Request, is there any problem with this command? And if I want to make this into a timerec/create, is it possible or do I need some basic config? Thanks for the replies in advance.


Replies (9)

RE: Accessing TVHeadend through API - Added by Dave Pickles over 4 years ago

Unfortunately, as you've found, TVH doesn't tell you what is wrong, just gives a generic error message. I presume you're including a username and password with your curl request? Also the "title" parameter must include the language as in the API docs:

"title": {
"eng": "my title"
},

RE: Accessing TVHeadend through API - Added by Je Yen Chen over 4 years ago

curl --data conf={"disp_title":"mcd","channelname":"Mnet","start":1581612630,"stop":1581619830,"start_extra":4,"stop_extra":4,"pri":0,"config_name":""} http://39.118.67.14:9981/api/dvr/entry/create

What if I just remove "title" and replace that with "disp_title"?

RE: Accessing TVHeadend through API - Added by Dave Pickles over 4 years ago

You would need to check in the source code which items are actually necessary, but I would expect title would be needed.

Try copying the example in https://github.com/dave-p/TVH-API-docs/wiki/Dvr#dvrentrycreate and work from there.

RE: Accessing TVHeadend through API - Added by Je Yen Chen over 4 years ago

I have it figured out now, it's working with /dvr/entry/create but right now I want to figure out /dvr/timerec/create, I tried

{"enabled":true,"name":"Simplykpop","title":"%F_%R_simplykpop","channel":"d9b927a76f3e913d10462c30282c3df0","start":"11:50","stop":"13:50","weekdays":[5],"pri":2,"retention":0,"removal":0,"config_name":"ccb9dce496903e2179c04b321cede6c2","creator":"127.0.0.1"}

But it gave out 400 Bad Request, am I not entering anything right here?

RE: Accessing TVHeadend through API - Added by Dave Pickles over 4 years ago

This works for me:

curl --data-urlencode 'conf={"enabled":true,"name":"Simplykpop","title":"%F_%R_simplykpop","channel":"00e4eb43b15b33d23521143067e0a685","start":"11:50","stop":"13:50","weekdays":[5],"pri":2,"retention":0,"removal":0,"config_name":"1ccca1a328ecdcab3f88640dda5b6209","creator":"myuser","owner":"myuser"}' http://myuser:[email protected]:9981/api/dvr/timerec/create

Both "owner" and "creator" must be valid usernames, and "config_name" must be a valid recording profile.

RE: Accessing TVHeadend through API - Added by Je Yen Chen over 4 years ago

How do I know a valid profile? Can I just use the same config that exists with other Timerec config?

RE: Accessing TVHeadend through API - Added by Dave Pickles over 4 years ago

If you specify "config_name":"" the default recording profile is used. To use a different profile use api/dvr/config/grid to list the profiles and use the uuid of the appropriate one.

RE: Accessing TVHeadend through API - Added by Je Yen Chen over 4 years ago

I have got my profile, but is both "Owner" and "Creator" necessary? Or can that be skipped?

RE: Accessing TVHeadend through API - Added by Dave Pickles over 4 years ago

I don't know. Both are mentioned in the code. You could try missing out one or both of them, but why bother?

    (1-9/9)