简体   繁体   中英

How to send .csv file using cURL in python

I have API and I need to send a .csv file using cURL in python. I do not know how to write this command on python.

curl --location --request POST 'http://**************' \
--header 'Accept: application/json' \
--header 'API-AUTH-TOKEN: **************' \
--form 'list=@"/C:/Users/1288956/Downloads/ozon_search_query_test.csv"'
    • means I can't show it

RJ Adriaansen gave me a good answer: curlconverter.com

import requests

headers = {
    'Accept': 'application/json',
    'API-AUTH-TOKEN': '**************',
}

files = {
    'list': ('"/C:/Users/1288956/Downloads/ozon_search_query_test.csv"', open('"/C:/Users/1288956/Downloads/ozon_search_query_test.csv"', 'rb')),
}

response = requests.post('http:///**************', headers=headers, files=files)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM