POST /write.php HTTP/1.1
HOST: upload.sitename.com
accept-encoding: gzip, deflate
content-length: 788
content-type: multipart/form-data; boundary=----WebKitFormBoundarycHb9L3gZr8gzENfz
referer: http://www.sitename.com
user-agent: sitename.app
------WebKitFormBoundarycHb9L3gZr8gzENfz
Content-Disposition: form-data; name="app_id";
123123123123
------WebKitFormBoundarycHb9L3gZr8gzENfz
Content-Disposition: form-data; name="id";
idididid
------WebKitFormBoundarycHb9L3gZr8gzENfz
Content-Disposition: form-data; name="mode";
write
------WebKitFormBoundarycHb9L3gZr8gzENfz
Content-Disposition: form-data; name="subject";
subject
------WebKitFormBoundarycHb9L3gZr8gzENfz
Content-Disposition: form-data; name="user_id";
456456456456
------WebKitFormBoundarycHb9L3gZr8gzENfz
Content-Disposition: form-data; name="memo_block[0]";
memoblock
------WebKitFormBoundarycHb9L3gZr8gzENfz--
I want to send this request using python.
import requests
from email.mime.multipart import MIMEMultipart
related = MIMEMultipart('form-data','----WebKitFormBoundary6o6EZLygJtLbQhjb')
headers = dict(related.items())
headers['User-Agent'] = 'sitename.app'
headers['referer'] = 'http://www.sitename.com'
files = {
'app_id':(None, '123123'),
'id':(None, 'idid'),
'mode':(None, 'write'),
'subject':(None, 'subject'),
'user_id':(None, '456456'),
'memo_block[0]':(None, 'memoblock')
}
req = requests.post('http://upload.sitename.com/_app_write_api.php', files=files, headers=headers)
print(req.status_code)
So, I wrote code like this.
I identified request using Wire Shark, but it is not that I want.
POST /_app_write_api.php HTTP/1.1
Host: upload.sitename.com
User-Agent: sitename.app
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Type: multipart/form-data; boundary="----WebKitFormBoundary6o6EZLygJtLbQhjb"
MIME-Version: 1.0
referer: http://www.sitename.com
Content-Length: 680
--e68a0877353c411b8972ec5f868b2e41
Content-Disposition: form-data; name="app_id"
123123
--e68a0877353c411b8972ec5f868b2e41
Content-Disposition: form-data; name="id"
idid
--e68a0877353c411b8972ec5f868b2e41
Content-Disposition: form-data; name="mode"
write
--e68a0877353c411b8972ec5f868b2e41
Content-Disposition: form-data; name="subject"
subject
--e68a0877353c411b8972ec5f868b2e41
Content-Disposition: form-data; name="user_id"
456456
--e68a0877353c411b8972ec5f868b2e41
Content-Disposition: form-data; name="memo_block[0]"
memoblock
--e68a0877353c411b8972ec5f868b2e41--
actually send request like this. And server send response 'error' to me.
I think that it occur because '--e68a0877353c411b8972ec5f868b2e41'.
How can I set this? or can I set boundary randomly?