Add a new show with Curl (using PHP and exec)

Sonarr version (exact version): 2.0.0.5344
Mono version (if Sonarr is not running on Windows): 5.18.0.240
OS: Raspbian
Description of issue: Trying to get a show added with the API

I’m not really a dev and just playing with this , but i have managed to grab all the info needed with a curl request and a tcdb id , so that part is working , but i assume i cant just use the same style to add the show to sonarr ?

curl -L --request POST “http://localhost:8989/series/?tvdbId=247897&title=Homeland&qualityProfileId=0&titleSlug=homeland&seasons[0][seasonNumber]=1&seasons[0][monitored]=true&seasons[1][seasonNumber]=2&seasons[1][monitored]=true&seasons[2][seasonNumber]=3&seasons[2][monitored]=true&seasons[3][seasonNumber]=4&seasons[3][monitored]=true&seasons[4][seasonNumber]=5&seasons[4][monitored]=true&seasons[5][seasonNumber]=6&seasons[5][monitored]=true&seasons[6][seasonNumber]=7&seasons[6][monitored]=true&seasons[7][seasonNumber]=8&seasons[7][monitored]=true&seasons[8][seasonNumber]=9&seasons[8][monitored]=true&seasons[9][seasonNumber]=10&seasons[9][monitored]=true&path=/mnt/shows/Homeland&seasonFolder=false&monitored=true&apikey={removed the api key}”

How would i do this with the info for show 247897 (or any really)

Thanks in advance , i have searched but i find myself getting lost and going in circles.

Have you read through the API documentation on the WIKI?

You’re missing /api from the URL.

This needs to be sent as JSON in the POST body, not query string parameters.

Thanks Markus101,

Ive also tried curl -L --request POST “http://localhost:8989/api/series/?tvdbId=247897&title=Homeland&qualityProfileId=0&titleSlug=homeland&seasons[0][seasonNumber]=1&seasons[0][monitored]=true&seasons[1][seasonNumber]=2&seasons[1][monitored]=true&seasons[2][seasonNumber]=3&seasons[2][monitored]=true&seasons[3][seasonNumber]=4&seasons[3][monitored]=true&seasons[4][seasonNumber]=5&seasons[4][monitored]=true&seasons[5][seasonNumber]=6&seasons[5][monitored]=true&seasons[6][seasonNumber]=7&seasons[6][monitored]=true&seasons[7][seasonNumber]=8&seasons[7][monitored]=true&seasons[8][seasonNumber]=9&seasons[8][monitored]=true&seasons[9][seasonNumber]=10&seasons[9][monitored]=true&path=/mnt/shows/Homeland&seasonFolder=false&monitored=true&apikey={removed my api key}”

I have tried to follow the documentation on the wiki but there is no clear examples which for me is very confusing. Ive been trying different things for about 2 days now and none of the things i try seem to work which is why i finally gave in and decided to post.

I did get the lookup part working and im able to get the data i require from that , but no matter what i seem to try i cant get the add side of it to work

curl --request GET “http://localhost:8989/api/series/lookup/?term=tvdb:247897&apikey={ap removed}” … I can get everything i need from this , but an example of a Curl would be great if someone could provide one please .

That’s also not using a post body.

Look at how the UI does it, in Chrome you can have it dump out the curl command I believe.

Thanks for confirming what I have already discovered and the reason I posted here in the first place. Most forums i have ever read,people have been helpful . Here you seen to just point out the obvious and dont really help, but thanks for commenting

Do you want help in figuring it out or do you want it on a silver platter? I can point you in the right direction, but I’m not going to give you a curl command you can run, you’ll have to do some of the leg work yourself.

I pointed out that has the same problem, because beyond using the correct URL it had the same issue, it is not using a post body to submit.

Googling curl post body yields this as the first result: https://gist.github.com/subfuzion/08c5d85437d5d4f00e58 which has several examples and if you scroll to the end of the post you get an example on how to curl with a post body (bonus, application/json which Sonarr uses): https://gist.github.com/subfuzion/08c5d85437d5d4f00e58#post-applicationjson

There is also an example at the bottom of the Sonarr API docs page: https://github.com/Sonarr/Sonarr/wiki/API#linux-curl-missingepisodesearch-example

I also pointed out you can look at how the UI does it, because the UI uses the API and if you right click a request in the network tab you get the option to copy as cURL:
image

Many thanks , thats actually useful information there - as i said im not a developer so taking a stab at things and its a bit harder to get information i understand sometimes. I got the copy thing working and found the curl i needed so ill give that a try over the next few days , appreciate the clear direction.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.