Skip to content

Fix Flex Web Service endpoints (legacy URLs return 1001)#108

Merged
csingley merged 2 commits into
csingley:masterfrom
eyalk11:fix-flex-endpoints
May 23, 2026
Merged

Fix Flex Web Service endpoints (legacy URLs return 1001)#108
csingley merged 2 commits into
csingley:masterfrom
eyalk11:fix-flex-endpoints

Conversation

@eyalk11
Copy link
Copy Markdown
Contributor

@eyalk11 eyalk11 commented May 16, 2026

Summary

  • The legacy gdcdyn.interactivebrokers.com/Universal/servlet/FlexStatementService.{SendRequest,GetStatement} endpoints now consistently return <Status>Fail</Status> with <ErrorCode>1001</ErrorCode> ("Statement could not be generated at this time"), breaking every download.
  • IB has moved the service to AccountManagement/FlexWebService/... paths. Updated REQUEST_URL and STMT_URL accordingly.
  • Also includes a prior fix removing a hardcoded override of REQUEST_URL that pointed at a 404 HTML endpoint and caused infinite retry loops.

New endpoints:

  • SendRequest: https://ndcdyn.interactivebrokers.com/AccountManagement/FlexWebService/SendRequest
  • GetStatement: https://gdcdyn.interactivebrokers.com/AccountManagement/FlexWebService/GetStatement

Test plan

  • Verified end-to-end against a live Flex token/query: 74KB FlexQueryResponse returned successfully.
  • Existing unit tests still pass (they reference client.REQUEST_URL/STMT_URL symbolically and mock requests.get).

eyalk11 and others added 2 commits April 24, 2026 14:26
request_statement() was unconditionally overriding the correct
REQUEST_URL (https://gdcdyn.interactivebrokers.com/Universal/servlet/
FlexStatementService.SendRequest) with
https://ndcdyn.interactivebrokers.com/portal.flexweb/api/v1/flexQuery.

That second URL does not exist -- IB responds with a generic HTML
"404 Page Not Found" (~11KB). Because the body is HTML rather than
the Flex XML error envelope, parse_stmt_response() can't turn it into
a StatementError, so no ResponseCodeError is raised and callers loop
indefinitely retrying the dead endpoint.

The correct gdcdyn/Universal/servlet/FlexStatementService.SendRequest
endpoint is still live and returns a proper <ReferenceCode> for valid
token/query pairs (verified against a live Flex token). Dropping the
override lets `url = url or REQUEST_URL` stand, restoring working
downloads.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The legacy gdcdyn/Universal/servlet/FlexStatementService.{SendRequest,
GetStatement} endpoints now return Fail with ErrorCode 1001
("Statement could not be generated at this time"), making downloads
fail for every token/query pair.

IB has moved the service to:
  SendRequest:  ndcdyn.interactivebrokers.com/AccountManagement/FlexWebService/SendRequest
  GetStatement: gdcdyn.interactivebrokers.com/AccountManagement/FlexWebService/GetStatement

Verified against a live token/query: SendRequest returns a proper
<ReferenceCode>, and GetStatement returns the full FlexQueryResponse.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@montehoover
Copy link
Copy Markdown
Collaborator

@eyalk11 I'm looking for a way to continue using this library. I sent a message to @csingley about adding new maintainers to the repo but I think he is caught up with other projects at the moment. Any interest in making a new fork intended to be maintained by small group of folks, perhaps including @tbarnier and @ANDREW251 from #104 and #107?

If @csingley circles back to this, we could re-merge the fork.

@csingley csingley merged commit 7ae2c47 into csingley:master May 23, 2026
@csingley
Copy link
Copy Markdown
Owner

Sorry to be AWOL and unresponsive. I just made bail; my first action on the outside was to merge this commit, and my next has been to invite @montehoover to help keep the lamps around here trimmed and burning in case I get sent back up the river again.

@csingley
Copy link
Copy Markdown
Owner

Y'all are of course welcome to fork the code if all else fails, but that just tends to confuse people - let's try to make the repo pointed at by search engines just not suck instead. Again, my apologies - everyone's contributions are much appreciated while I have been incommunicado in the deepest forests of Borneo.

@montehoover
Copy link
Copy Markdown
Collaborator

Glad this repo is staying alive! I'm happy to help in any way I can. And I'm excited for ibflex 1.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants