Created
January 28, 2020 09:07
-
-
Save JosephineAkello/12ab20e7ace54a4ecaad616a945aa877 to your computer and use it in GitHub Desktop.
This is a Python script that enables patching of different IDs from different columns in the db, into one column using the available endpoint.
This file contains 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
import json | |
import requests | |
from providerProgramContracts.helpers import open_csv | |
def patch_ids(): | |
my_token = 'enter your token here' | |
count = 0 | |
results = [] | |
headers = { | |
'Content-Type': "application/json", | |
'Authorization': f"Bearer {my_token}" | |
} | |
record_lists = open_csv('myCSVfile.csv') | |
for ids in record_lists: | |
payload = {} | |
response = requests.patch( | |
f'http://your-url.com/program-contracts/{ids[0]}/bank-accounts?bankAccountId={ids[1]}', | |
data=json.dumps(payload), headers=headers) | |
one_result = { | |
'record_list': record_lists, | |
'response': response.status_code, | |
'message': response.text | |
} | |
count += 1 | |
print(count, one_result) | |
results.append(one_result) | |
patch_ids() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment