我试图用python请求创建multipart / form-data。 解决方案应该返回大的csv文件。
但我发布此类请求时遇到问题(原始来自Fiddler):
POST http://fix-cloud.sbis.ru/view_log/service/sbis-rpc-service300.dll?raw_file_result HTTP/1.1
Host: fix-cloud.sbis.ru
Connection: keep-alive
Content-Length: 579
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://fix-cloud.sbis.ru
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary0FyoqFD3QVSl0bly
Referer: http://fix-cloud.sbis.ru/cloud.html
Accept-Encoding: gzip, deflate
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Cookie: _ym_uid=1455544058672406990; __utma=60092399.1077522409.1455548286.1455548286.1455548286.1; __utmz=60092399.1455548286.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); timeToCheck=Wed%2C%2024%20Feb%202016%2016%3A18%3A51%20GMT; param=viewer; did=fb1a4666-e652-4f87-abb4-8fbc445bc20d; rightshash=c7b7b64c088c681b0ff84407076cad18; CpsUserId=; tz=-180; RT=; su=00000001-00056a83; sid=00000001-00056a83-00ba-6847661894264e9c
------WebKitFormBoundary0FyoqFD3QVSl0bly
Content-Disposition: form-data; name="Запрос"
{"jsonrpc":"2.0","protocol":4,"method":"ЖурналСообщений.Выгрузить","params":{"Параметры":{"s":[{"t":"Строка","n":"ВремяОт"},{"t":"Строка","n":"ВремяДо"},{"t":"Строка","n":"Группа"}],"d":["2016-02-24 19:18:03.500+03","2016-02-24 19:19:03.500+03","Основной сервис inside"],"_type":"record"},"fileDownloadToken":7140344178769737},"id":"4117712937295437"}
------WebKitFormBoundary0FyoqFD3QVSl0bly--
这不正确。当我试图获取非常大的文件时,服务器返回答案504。
r = s.post(csv_url, headers = post_headers, data = json.dumps(data))
该解决方案无论如何都无法奏效。它回答为500
r = s.post(csv_url, headers = post_headers, files = {'Запрос':(None, json.dumps(data), None)})
卷曲命令
curl 'http://fix-cloud.sbis.ru/view_log/service/sbis-rpc-service300.dll?raw_file_result' -H 'Host: fix-cloud.sbis.ru' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3' -H 'Accept-Encoding: gzip, deflate' -H 'Referer: http://fix-cloud.sbis.ru/cloud.html' -H 'Cookie: param=viewer; CpsUserId=; did=238ebefa-ec52-4c41-a1d7-8a14fcfdeae4; timeToCheck=Thu%2C%2025%20Feb%202016%2010%3A48%3A55%20GMT; rightshash=c7b7b64c088c681b0ff84407076cad18; tz=-180; RT=; sid=00000001-00056a83-00ba-ffbbb027145646c3; su=00000001-00056a83' -H 'Connection: keep-alive' -H 'Content-Type: multipart/form-data; boundary=---------------------------12195194351941' --data-binary $'-----------------------------12195194351941\r\nContent-Disposition: form-data; name="\u0417\u0430\u043f\u0440\u043e\u0441"\r\n\r\n{"jsonrpc":"2.0","protocol":4,"method":"\u0416\u0443\u0440\u043d\u0430\u043b\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.\u0412\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u044c","params":{"\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b":{"s":[{"t":"\u0421\u0442\u0440\u043e\u043a\u0430","n":"\u0412\u0440\u0435\u043c\u044f\u041e\u0442"},{"t":"\u0421\u0442\u0440\u043e\u043a\u0430","n":"\u0412\u0440\u0435\u043c\u044f\u0414\u043e"},{"t":"\u0421\u0442\u0440\u043e\u043a\u0430","n":"\u0413\u0440\u0443\u043f\u043f\u0430"}],"d":["2016-02-25 14:40:02.900+03","2016-02-25 14:40:02.900+03","\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 inside"],"_type":"record"},"fileDownloadToken":36597679759578120},"id":"9150478717440579"}\r\n-----------------------------12195194351941--\r\n'