The --data-urlencode parameter is not part of the URL, it merely tells curl how to encode the data being posted, so you do not pass that portion to TIdHTTP at all.
The part of the curl command between single quotes is the actual data to post. --data-urlencode tells curl to send the data using the HTTP POST method, using the application/x-www-form-urlencoded content type, and url-encoding the data.
The TStrings version of TIdHTTP.Post() does all of that. Normally, application/x-www-form-urlencoded is used with "name=value" string pairs, however there is no name being specified in the curl command, only a value. If curl supplies a default name, then the Delphi code would look like this:
procedure TfrmMain.get1Click(Sender: TObject);
var
json: string;
lHTTP: TIdHTTP;
lParamList: TStringList;
result:string;
begin
json := CRLF +
'{' + CRLF +
' "resource_id": "391792b5-9c0a-48a1-918f-2ee63caa1c54",' + CRLF +
' "filters": {' + CRLF +
' "provider_id": 393303' + CRLF +
' }' + CRLF +
'}';
lParamList := TStringList.Create;
try
lParamList.Add('somename='+json);
lHTTP := TIdHTTP.Create(nil);
try
Result := lHTTP.Post('http://hub.Healthdata.gov/api/action/datastore_search', lParamList);
finally
lHTTP.Free;
end;
finally
lParamList.Free;
end;
end;
Otherwise, if curl sends the specified data as-is by itself, then the Delphi code would look like this instead:
procedure TfrmMain.get1Click(Sender: TObject);
var
json: string;
lHTTP: TIdHTTP;
lParamList: TStringList;
result:string;
begin
json := CRLF +
'{' + CRLF +
' "resource_id": "391792b5-9c0a-48a1-918f-2ee63caa1c54",' + CRLF +
' "filters": {' + CRLF +
' "provider_id": 393303' + CRLF +
' }' + CRLF +
'}';
lParamList := TStringList.Create;
try
lParamList.Add(json);
lHTTP := TIdHTTP.Create(nil);
try
Result := lHTTP.Post('http://hub.Healthdata.gov/api/action/datastore_search', lParamList);
finally
lHTTP.Free;
end;
finally
lParamList.Free;
end;
end;
The only difference being what parameter value gets passed to TStringList.Add().