This library can help you with fetching flex queries from Interactive Brokers. Just pass Token and Query ID and wait until it has finished.
Simple call the library by passing your token and queryId:
...
FlexResult result = new Reader().GetByApi(token, queryId).Result;
...
Or pass an already downloaded file:
...
FlexQueryResponse result = new Reader().GetByString(content);
...
nuget install Biehler.IbFlexReader
It requires your application to be .NET Standard 2.0 compliant.
Please read the wiki to be informed about the required IB setup.