SplitText('&', web_url, StrList);
What is the actual value of web_url?
StrList[0] := StringReplace(StrList[0],' ','%20',[rfReplaceAll]);
Why are you doing that? And only for the first string and not the other strings?
In "application/x-www-form-urlencoded", spaces are encoded as "+", not as "%20". And besides, TIdHTTP.Post() already encodes spaces for you. What you are doing is problematic if any "%" characters belonging to urlencoded sequences end up in your TStringList strings, because TIdHTTP.Post() will re-encode them as "%25" instead of leaving them as "%", thus corrupting the data the server sees. Unless you disable the hoForceEncodeParams flag in the TIdHTTP.HTTPOptions property (it is enabled by default).
Data.Values['q'] := copy(StrList[0],POS('=',StrList[0])+1, Length(StrList[0]));
Data.Values['key'] := copy(StrList[1],POS('=',StrList[1])+1, Length(StrList[1]));
Data.Values['secret'] := copy(StrList[2],POS('=',StrList[2])+1, Length(StrList[2]));
Data.Values['per_page'] := copy(StrList[3],POS('=',StrList[3])+1, Length(StrList[3]));
Data.Values['page'] := copy(StrList[4],POS('=',StrList[4])+1, Length(StrList[4]));
You are assuming the StrList values are in the same order as the Data values. I would do it more dynamically instead:
for I := 0 to StrList.Count-1 do
begin
J := Pos('=', StrList[I]);
Data.Values[Copy(StrList[I], 1, J-1)] := Copy(StrList[I], J+1, MaxInt);
end;
Or simpler:
for I := 0 to StrList.Count-1 do
begin
Data.Values[StrList.Names[I]] := StrList.ValueFromIndex[I];
end;
Or, since the strings are clearly already in "name=value" format, just add them as-is instead:
for I := 0 to StrList.Count-1 do
Data.Add(StrList[I]);
Or simpler:
Data.Assign(StrList);
In which case, you don't need two separate TStringLists at all. Get rid of Data and post StrList as-is instead:
Result := HTTP1.Post('https://api.discogs.com/database/search', StrList);
Or, if web_url is already in "application/x-www-form-urlencoded" format to begin with (such as if are extracting it from the query portion of a URL), then just post it as-is without parsing it at all:
Strm := TStringStream.Create(web_url);
Result := HTTP1.Post('https://api.discogs.com/database/search', Strm);
Strm.Destroy;
The error only occurs when I try to POST
That usually means you are corrupting the data you are posting.
any other request works perfectly using the GET (e.g. everything w/o "per_page")
Sure, because you are not sending any data to the server, you are requesting data from the server instead.