cURL commands to the API to turn off RSS feed for Indexer

I am a complete novice to API and cURL. Anyway, I was told in another topic that I could use Chrome Dev. Tools to find the commands sent to the API and then copy them as cURL commands.

I wanted to use these commands from the windows command prompt to turn off (or on) the RSS feed for an Indexer.

I opened the settings for an Indexer by clicking on the “RSS” image, turned off the RSS feed and clicked “Save”. These are the commands that were recorded:


The first two (data.image/png:base…) are not relevant as they were recorded when I clicked on the “RSS” image. I assume that one or all of the next three commands, that were generated when I clicked on “Save”, are needed to turn of the the RSS feed.
Which command(s) are relevant?

I copied all three as cURL commands and tried to execute them from the command prompt, but they all generated errors.
Here is the error from the first cURL command “13”:

curl: option -: is unknown
curl: try ‘curl --help’ or ‘curl --manual’ for more information

Is this approach flawed? Any help to a novice in this area would be much appreciated!
Should I post all 3 cURL commands here with the errors?

Hi,

Only the “13” request is relevant. If you go to the Chrome dev tools -> Network -> click the “13” request, you’ll see that it actually calls /api/indexer/13

Screenshot from my config (indexer 7, url removed):

Hope that helps you a bit on your way…

Thanks Thirrian,
I suspected that “13” was the relevant one. However, when I run the copied cURL command:

curl “http://localhost:38082/api/indexer/13” -X PUT -H “Authorization: Basic cmJyYW5kZTprb21paGFn” -H “Origin: http://localhost:38082” -H “Accept-Encoding: gzip, deflate, br” -H “Accept-Language: en-US,en;q=0.8” -H “User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36” -H “Content-Type: application/json” -H “Accept: application/json, text/javascript, /; q=0.01” -H “Referer: http://localhost:38082/settings/indexers” -H “X-Requested-With: XMLHttpRequest” -H “Cookie: _pk_id.1.1fff=7ff1be8da507d351.1495686018.1.1495686018.1495686018.; user=^^“2^|1:0^|10:1501303111^|4:user^|44:MmY1ZTMxNDFjYzk4NDE0MGFkZDRiN2IyYjU4MTVmZTI=^|a5a0ae51d2eedb3b19470ce6352ba303a3a2a9aaef79cbac855adabebad4c474^^”; snatched_view=list; soon_view=thumb; suggest_view=thumb; late_view=list; imdb_box_office_view=thumb; imdb_top_dvd_rentals_view=thumb” -H “Connection: keep-alive” -H “X-Api-Key: SonarrAPIkey” --data-binary “^{^^“enableRss^^”:false,^^“enableSearch^^”:false,^^“supportsRss^^”:true,^^“supportsSearch^^”:true,^^“protocol^^”:^^“usenet^^”,^^“name^^”:^^“N. NZBFinder.ws ^^”,^^“fields^^”:^[^{^^“order^^”:0,^^“name^^”:^^“BaseUrl^^”,^^“label^^”:^^“URL^^”,^^“value^^”:^^“https://nzbfinder.ws^^”,^^“type^^”:^^“textbox^^”,^^“advanced^^”:false^},^{^^“order^^”:1,^^“name^^”:^^“ApiPath^^”,^^“label^^”:^^“API Path^^”,^^“helpText^^”:^^“Path to the api, usually /api^^”,^^“value^^”:^^”/api^^",^^“type^^”:^^“textbox^^”,^^“advanced^^”:true^},^{^^“order^^”:2,^^“name^^”:^^“ApiKey^^”,^^“label^^”:^^“API Key^^”,^^“value^^”:^^“IndexerAPIkey^^”,^^“type^^”:^^“textbox^^”,^^“advanced^^”:false^},^{^^“order^^”:3,^^“name^^”:^^“Categories^^”,^^“label^^”:^^“Categories^^”,^^“helpText^^”:^^“Comma Separated list, leave blank to disable standard/daily shows^^”,^^“value^^”:^[5010,5030,5040,5045^],^^“type^^”:^^“textbox^^”,^^“advanced^^”:false^},^{^^“order^^”:4,^^“name^^”:^^“AnimeCategories^^”,^^“label^^”:^^“Anime Categories^^”,^^“helpText^^”:^^“Comma Separated list, leave blank to disable anime^^”,^^“value^^”:^[^],^^“type^^”:^^“textbox^^”,^^“advanced^^”:false^},^{^^“order^^”:5,^^“name^^”:^^“AdditionalParameters^^”,^^“label^^”:^^“Additional Parameters^^”,^^“helpText^^”:^^“Additional Newznab parameters^^”,^^“type^^”:^^“textbox^^”,^^“advanced^^”:true^}^],^^“implementationName^^”:^^“Newznab^^”,^^“implementation^^”:^^“Newznab^^”,^^“configContract^^”:^^“NewznabSettings^^”,^^“infoLink^^”:^^"https://github.com/Sonarr/Sonarr/wiki/Supported-Indexers^#newznab^^",^^“id^^”:13^}" --compressed
(with “–compressed” removed)

I get the error:

curl: option -: is unknown
curl: try ‘curl --help’ or ‘curl --manual’ for more information

I don’t understand whet the “option -” or “option -:” refers to,., How would I troubleshoot the command?

p,s. I replaced my API key with “SonarrAPIkey”

I don’t think you can use -H multiple times, and there’s no need to… you don’t need all that stuff. Only the X-Api-Key.
See API docs: https://github.com/Sonarr/Sonarr/wiki/API

If you open the wiki for a particular API call, you’ll notice that they’re all pretty much the same. If you want to use PUT, you basically have to submit a request with the same json as returned by GET (with whatever values modified to what you want ofcourse).

So try this one first to get the json:

curl -H "X-Api-Key: YOUR_API_KEY" http://HOSTNAME:PORT/api/indexer/INDEXERNUMBER

Holy crap that’s a lot of json :wink::

{
  "enableRss": false,
  "enableSearch": true,
  "supportsRss": true,
  "supportsSearch": true,
  "protocol": "usenet",
  "name": "redacted",
  "fields": [
    {
      "order": 0,
      "name": "BaseUrl",
      "label": "URL",
      "value": "redacted",
      "type": "textbox",
      "advanced": false
    },
    {
      "order": 1,
      "name": "ApiPath",
      "label": "API Path",
      "helpText": "Path to the api, usually /api",
      "value": "/api",
      "type": "textbox",
      "advanced": true
    },
    {
      "order": 2,
      "name": "ApiKey",
      "label": "API Key",
      "value": "redacted",
      "type": "textbox",
      "advanced": false
    },
    {
      "order": 3,
      "name": "Categories",
      "label": "Categories",
      "helpText": "Comma Separated list, leave blank to disable standard/daily shows",
      "value": [
        redacted
      ],
      "type": "textbox",
      "advanced": false
    },
    {
      "order": 4,
      "name": "AnimeCategories",
      "label": "Anime Categories",
      "helpText": "Comma Separated list, leave blank to disable anime",
      "value": [],
      "type": "textbox",
      "advanced": false
    },
    {
      "order": 5,
      "name": "AdditionalParameters",
      "label": "Additional Parameters",
      "helpText": "Additional Newznab parameters",
      "type": "textbox",
      "advanced": true
    }
  ],
  "implementationName": "Newznab",
  "implementation": "Newznab",
  "configContract": "NewznabSettings",
  "infoLink": "https://github.com/Sonarr/Sonarr/wiki/Supported-Indexers#newznab"
,
  "id": 12
}

You’re probably only interested in "enableRss": false,
So you’d basically set that to true or false or whatever and send the entire json with curl’s -X PUT to the same /api/indexer/xx endpoint.

That should do it.

Thanks again!
I executed

curl -H “X-Api-Key: YOUR_API_KEY” “http://localhost:38082/api/indexer/13

and got the JSON which I copied from the Windows command prompt.
I then used notepad++ to do an EOL conversion of the JSON from Windows (CR LF) to Unix (LF) .

What is the syntax of the PUT?
I tried this (following the syntax of the copied cURL command from Chrome Dev tools)

curl “http://localhost:38082/api/indexer/13” -X PUT -H {JSON} “X-Api-Key: YOUR_API_KEY”

However, it didn’t work.Here are the first couple of errors in the response:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>
curl: (6) Could not resolve host: enableRss
curl: (6) Could not resolve host: false

,

You may want to convert all end of line characters to a space (CR+LF --> space or LF --> space).

You forgot the -d switch for data and put your json in between -H and the header. Data (on Windows at least, not sure about other platforms) is enclosed in quotes. Also, depending on the platform etc, you want to escape quotes inside the data payload with a backslash.

Complete example (with some values omitted so people don’t get my sonarr / indexer api keys etc:

curl http://SONARRSERVER:PORT/api/indexer/INDEXER_ID -X PUT -H "X-Api-Key: SONARR_API_KEY" -d "{\"enableRss\":false,\"enableSearch\":true,\"supportsRss\":true,\"supportsSearch\":true,\"protocol\":\"usenet\",\"name\":\"INDEXERNAME\",\"fields\":[{\"order\":0,\"name\":\"BaseUrl\",\"label\":\"URL\",\"value\":\"https://MY.INDEXER.COM\",\"type\":\"textbox\",\"advanced\":false},{\"order\":1,\"name\":\"ApiPath\",\"label\":\"API Path\",\"helpText\":\"Path to the api, usually /api\",\"value\":\"/api\",\"type\":\"textbox\",\"advanced\":true},{\"order\":2,\"name\":\"ApiKey\",\"label\":\"API Key\",\"value\":\"INDEXER_API_KEY\",\"type\":\"textbox\",\"advanced\":false},{\"order\":3,\"name\":\"Categories\",\"label\":\"Categories\",\"helpText\":\"Comma Separated list, leave blank to disable standard/daily shows\",\"value\":[5000],\"type\":\"textbox\",\"advanced\":false},{\"order\":4,\"name\":\"AnimeCategories\",\"label\":\"Anime Categories\",\"helpText\":\"Comma Separated list, leave blank to disable anime\",\"value\":[],\"type\":\"textbox\",\"advanced\":false},{\"order\":5,\"name\":\"AdditionalParameters\",\"label\":\"Additional Parameters\",\"helpText\":\"Additional Newznab parameters\",\"type\":\"textbox\",\"advanced\":true}],\"implementationName\":\"Newznab\",\"implementation\":\"Newznab\",\"configContract\":\"NewznabSettings\",\"infoLink\":\"https://github.com/Sonarr/Sonarr/wiki/Supported-Indexers#newznab\",\"id\":INDEXER_ID}"

And yes. That is one line.

It works :grinning:! Thank you!
Actually, I didn’t “forget” the -d. I had no clue that I needed it.

I also needed to remove all spaces in the JSON for it to work. However, I didn’t need to enclose the JSON in quotes. It worked fine anyway (Windows 7). Maybe the curly brackets are enough.
Thanks again!

p.s. I will use in a batch file to turn on/off indexers at certain times of the day. I will post here again if I encounter any other issues with this.

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