try post to API with python :
import requests
import json
url='https://link.html'
data = {
'keyfile':{
'valuekey1': 'data1',
'valuekey2': 'data2'
}
}
payload = {'keypost': data}
headers = {
'Authorization': 'Bearer <token>',
#'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
}
response = requests.post(url, headers=headers, data=payload)
print(response)
print(response.text)
in API catch multipart form data with key "keypost" then get json with "keyfile" but the "keypost" and "keyfile" can't catch on API, what i'm wrong when send post data in python requests ?
[UPDATE] try to change payload with this and successfull:
payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"keypost\"\r\n\r\n{\"keyfile\": {\"valuekey1\": \"data1\", \"valuekey2\":\"data2\"}}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"
whats diferent payload 1 and payload 2:
data = { 'keyfile':{ 'valuekey1': 'data1', 'valuekey2': 'data2' } } payload = {'keypost': data}
------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"keypost\"\r\n\r\n{\"keyfile\": {\"valuekey1\": \"data1\", \"valuekey2\":\"data2\"}}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--
but i want still payload 1 because look simple ?