Skip to content

Commit

Permalink
sending "text/csv" as partial mime type in csv upload
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkahan committed May 4, 2023
1 parent edc7cb4 commit 69b88fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/vonage/proactive_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def delete_item(self, list_id: str, item_id: str):
auth_type=self._auth_type,
)

def download_list_items(self, list_id: str, file_path) -> List[dict]:
def download_list_items(self, list_id: str, file_path) -> list[dict]:
uri = f'https://{self._client.proactive_connect_host()}/v0.1/bulk/lists/{list_id}/items/download'
logger.debug(f"GET request sent to {repr(uri)}")
response = requests.get(
Expand All @@ -114,7 +114,11 @@ def upload_list_items(self, list_id: str, file_path: str):
uri = f'https://{self._client.proactive_connect_host()}/v0.1/bulk/lists/{list_id}/items/import'
with open(file_path, 'rb') as csv_file:
logger.debug(f"POST request sent to {repr(uri)}")
response = requests.post(uri, headers=self._client._add_jwt_to_request_headers(), files={'file': csv_file})
response = requests.post(
uri,
headers=self._client._add_jwt_to_request_headers(),
files={'file': ('list_items.csv', csv_file, 'text/csv')},
)
return self._client.parse(self._client.proactive_connect_host(), response)

def list_events(self, page: int = None, page_size: int = None):
Expand Down
7 changes: 4 additions & 3 deletions tests/data/proactive_connect/csv_to_upload.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'alice','1234'
'bob','5678'
'charlie','9012'
user,phone
alice,1234
bob,5678
charlie,9012

0 comments on commit 69b88fc

Please sign in to comment.