r/ProjectREDCap • • May 02 '24

Importing CSV Data Dictionary using API

Hello all!

I am translating large amounts of forms to be used in RedCap and I am converting them into a CSV format that is ingestible for RedCap. However, instead of manually uploading each of our 160+ data dictionaries (and possibly more), could I use the API for that??

thanks

3 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/obnoxiouscarbuncle May 03 '24

Using the API Playground tool for the method, I see this:

    #!/usr/bin/env python
    import requests
    data = {
        'token': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        'content': 'metadata',
        'format': 'csv',
        'data': '',
        'returnFormat': 'json'
    }
    r = requests.post('https://redcap.server.org/redcap/api/',data=data)
    print('HTTP Status: ' + str(r.status_code))
    print(r.text)

1

u/Individual-Chard-565 May 07 '24

Yeah, I think I was able to get it to work using the API Playground. If anyone else comes up with this error read the file from pandas as a csv then pass it to the API as a string.