API commands question

Sonarr version (exact version): 2.0.0.4753
OS: Windows Server 2016
Description of issue: Hi there.
Forgive me, if this is a stupid question, but I’ve failed to find an answer.
I’m trying to trigger a library update from powershell script. Could someone, please, tell me how to do this?

I’ve found this: https://github.com/Sonarr/Sonarr/wiki/Command , and I think I would have to use:
Invoke-WebRequest with this http://localhost:8989/api/command/{id}?apikey=${YOUR_API_KEY} ,
but I don’t know what command ID is for “Update library”.

Please, help :slight_smile: .

You need to use a POST to tell SOnarr to execute command and then you’d get the command ID back:

Please keep in mind that I’m a total noob when it comes to API interactions :smiley: .
Do you imply I should trigger a library scan for each series? I want to trigger a full library scan.

if you want to just trigger a full library scan and you are on windows you can run this in powershell.

$url = "http://localhost:8989/api/command"
$json = "{ ""name"": ""RescanSeries"" }"

Write-Host "Publishing update $version ($branch) to: $url"
Invoke-RestMethod -Uri $url -Method Post -Body $json -Headers @{"X-Api-Key"="YourAPIKey"}

only thing you need to change is the “YourAPIKey”(keep it in quotes) and it’ll work just fine.

1 Like

Oh, man. I was waaaaaay off :smiley: .
Thank you very much, @EightPixels :slight_smile: .

Not a problem at all ^^

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