From :RFC for HTTP (
https://tools.ietf.org/html/rfc7231#section-6.6.1[
^])
6.6.1. 500 Internal Server Error
The 500 (Internal Server Error) status code indicates that the server
encountered an unexpected condition that prevented it from fulfilling
the request.
It looks like the error may be related to how the server is handling the request.
If you were submitting a bad URL then most likely you'd get a 404 (resource not found) but that does depend upon the server too.
You should double-check your URL that is created though (by stepping through code) and then verify manually using a browser what happens with the generated URL.