diff --git a/sonarr.sh b/sonarr.sh index 242b85f..e40eaa7 100755 --- a/sonarr.sh +++ b/sonarr.sh @@ -45,14 +45,26 @@ api_get_query() { curl -s -G -H "$AUTH_HEADER" "$API/$path" "$@" } +# Payload goes through a temp file (curl -d @file), not as a command-line +# argument - a large library (e.g. Jeopardy's 1269-file import payload) can +# exceed the OS argument-length limit and fail with "Argument list too long" +# if passed directly via -d "$2". api_post() { + local payload_file + payload_file=$(mktemp) + printf '%s' "$2" > "$payload_file" curl -s -X POST -H "$AUTH_HEADER" -H "Content-Type: application/json" \ - -d "$2" "$API/$1" + -d "@$payload_file" "$API/$1" + rm -f "$payload_file" } api_put() { + local payload_file + payload_file=$(mktemp) + printf '%s' "$2" > "$payload_file" curl -s -X PUT -H "$AUTH_HEADER" -H "Content-Type: application/json" \ - -d "$2" "$API/$1" + -d "@$payload_file" "$API/$1" + rm -f "$payload_file" } # --------------------------------------------------------------------------