Change API parameters from comma-separated to arrays#110
Merged
pwildenhain merged 2 commits intoredcap-tools:masterfrom Mar 31, 2020
Merged
Conversation
https://community.projectredcap.org/questions/77217/export-records-api-silently-ignores-invalid-form-w.html According to Rob Taylor these parameters should not be comma-separated and represented as arrays instead.
Collaborator
|
Excellent work and write-up! Do we know how far back this is compatible API-wise? |
Contributor
Author
|
Rob says "not sure, but i do know that that particular API code in REDCap that deals with the API request parameters has not changed in the past 3 years, to my knowledge." |
Collaborator
|
Is there anything preventing this from being merged? |
Contributor
Author
|
@pwildenhain not that I'm aware of. My understanding is @sburns is continuing to maintain this as a favour in his spare time and he doesn't have a lot of that. |
Collaborator
|
Great! I've recently been made a collaborator on this repo, so I can help further develop and maintain this project. Since @sburns seemed primarily concerned with backwards-compatability, and you double-checked that with the developers, then I would say we're good to go! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
According to the REDCap developers multiple API parameters should not be comma-separated and should be represented as arrays instead. So I've changed PyCap to work in this way.
Background:
I noticed that when I passed an invalid form to
Project.export_records(), I got all records for all forms. If I passed valid forms I got the records I expected for just those forms.In the REDCap API playground (at least for version 9.5.13 which we're using) the example curl commands do not have the parameters comma-separated. Experimenting with curl:
In the first case I got:
{"error":"The following values in the parameter \"forms\" are not valid: 'flooble'"}In the second case it's as if the forms parameter was omitted and I get results for all forms. If I remove 'flooble' from the list of forms so the parameter is
forms=bmi,patient_recordI get results for just those two forms
I asked the question in the (members only) forum:
https://community.projectredcap.org/questions/77217/export-records-api-silently-ignores-invalid-form-w.html
and it seems that even though comma separated values is working in some cases, the REDCap developers say that the correct way to call the API is with arrays.
So I've changed
export_records(), export_metadata() and export_fem(). Oddly export_records() is the only call that returns a BadRequest if it gets and invalid form. So I'm also handling that.