The Wordnik Python API fails when including a comma separated list in the WordsApi.getRandomWord(excludePartOfSpeech) parameter. The failure symptom is that the server returns a 500 error.
This issue has been reported before, but only implicitly, and I can't find a discussion of root cause and remedies. The issue is that the API client library double encodes commas to %252C instead of %2C (comma encodes to %2C, %2C encodes to %252C). It looks like the server is not double decoding.
The below is my code (in Python):
apiUrl = 'http://api.wordnik.com/v4'
apiKey = '[redacted]'
client = swagger.ApiClient(apiKey, apiUrl)
wordsApi = WordsApi.WordsApi(client)
randomWord = wordsApi.getRandomWord(
The Wordnik Python API library generates this malformed request:
The request should look like this:
I could submit a pull request through GitHub to fix the issue, but this seems like a hack-y solution considering that the Wordnik Python API is automatically generated by Swagger. Can anyone on the Wordnik team address this issue?