1
votes

I do not have access of back end server and i analysed the API via network. I want to upload file using that API.I have observed that there are no parameters in post request to that API .I observed request payload in network .

Response Header

Cache-Control:no-cache Connection:keep-alive Content-Length:135 Content-Type:text/html; charset=utf-8 Date:Sat, 06 Aug 2016 14:32:00 GMT Location:http://myURL Server:nginx/1.2.3 Set-Cookie:_mystore2_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRkkiJTAxYzJhNTBkYmY3ZTRkYTBhYmY4NzhjNzdmNGY5OWRhBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMXB0WEl6NnZKSnF2ZVNCTTVXdnEzODdqWkc0cXFsN1RiTDB4d3o4WWo2aUE9BjsARkkiGXdhcmRlbi51c2VyLnVzZXIua2V5BjsAVFsISSIQU3ByZWU6OlVzZXIGOwBGWwZpAzggAUkiGXk0MTFIUTdVUktORkh2MzFCeEtFBjsARg%3D%3D--63863b861eb33b48b3137d187b2113fe90a930f3; path=/; HttpOnly Status:302 Found X-Rack-Cache:invalidate, pass X-Request-Id:3c843dc4dcb55bcf5f15e139264fa9be X-Runtime:0.884597 X-UA-Compatible:IE=Edge,chrome=1

Request Header

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8 Accept-Encoding:gzip, deflate Accept-Language:en-US,en;q=0.8 Cache-Control:no-cache Connection:keep-alive Content-Length:642389 Content-Type:multipart/form-data; boundary=----WebKitFormBoundary2rjUr5SSxx3BXjGn Cookie:s=; lat_lon=33.69%2673.0551; __utmt=1; _mystore2_session=BAh7CUkiD3Nlc3Npb25faWQGOgZFRkkiJTAxYzJhNTBkYmY3ZTRkYTBhYmY4NzhjNzdmNGY5OWRhBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMXB0WEl6NnZKSnF2ZVNCTTVXdnEzODdqWkc0cXFsN1RiTDB4d3o4WWo2aUE9BjsARkkiGXdhcmRlbi51c2VyLnVzZXIua2V5BjsAVFsISSIQU3ByZWU6OlVzZXIGOwBGWwZpAzggAUkiGXk0MTFIUTdVUktORkh2MzFCeEtFBjsARkkiCmZsYXNoBjsARm86JUFjdGlvbkRpc3BhdGNoOjpGbGFzaDo6Rmxhc2hIYXNoCToKQHVzZWRvOghTZXQGOgpAaGFzaHsHOg5hbmFseXRpY3NUOgxzdWNjZXNzVDoMQGNsb3NlZEY6DUBmbGFzaGVzewc7CnsIOg1jYXRlZ29yeUkiDENvbnRhY3QGOwBGOgthY3Rpb25JIhFsZWFkX2NhcHR1cmUGOwBGOgpsYWJlbEkiFFNlbGwgTW90b3JjeWNsZQY7AEY7C0kiLFVwbG9hZCBpbWFnZXMgdG8gYWN0aXZhdGUgeW91ciBsaXN0aW5nIQY7AEY6CUBub3cw--c3c1b5d437fd04a80dc888822811d2d4d354ae29; __utma=129180296.2104761345.1470477279.1470488831.1470491357.3; __utmb=129180296.10.9.1470493699533; __utmc=129180296; __utmz=129180296.1470477279.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none) Host:www.usedmotorcycles.net Origin:myURL Pragma:no-cache Referer:myURL Upgrade-Insecure-Requests:1 User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36

Request Payload

------WebKitFormBoundary2rjUr5SSxx3BXjGn Content-Disposition: form-data; name="utf8"

✓ ------WebKitFormBoundary2rjUr5SSxx3BXjGn Content-Disposition: form-data; name="authenticity_token"

ptXIz6vJJqveSBM5Wvq387jZG4qql7TbL0xwz8Yj6iA= ------WebKitFormBoundary2rjUr5SSxx3BXjGn Content-Disposition: form-data; name="image[attachment]"; filename="Screenshot (156).png" Content-Type: image/png

How i can use curl payload to submit my file?

1
I don't know why you expect us to debug this using only headers when the problem is possibly in your code. Check out the MVCE page on what would help your question alongMachavity♦
i have to observe from headers and request payload that what parameter should i sent ? this is post request and i did not observed form parametersAwais Mushtaq
I have observed that there are no parameters in post request to that API Wrong, there's a bunch of parameters, to name a few: Cookie:s, lat_lon, __utmt, _mystore2_session, __utma , AND MOREhanshenrik

1 Answers

1
votes

quote: I have observed that there are no parameters in post request to that API Wrong, there's a bunch of parameters, to name a few: Cookie:s, lat_lon, __utmt, _mystore2_session, __utma, AND MORE.

Also, that's not the complete request header you're showing us. for one, it's missing the request type (though its probably a POST request) anyway, to replicate this with curl, it's something like:

<?php 
$ch=curl_init();
curl_setopt_array($ch,array(
CURLOPT_URL=>'???',
CURLOPT_ENCODING=>'',
CURLOPT_POST=>true,
CURLOPT_POSTFIELDS=>array(
'Cookie:s'=>'',
'lat_lon'=>'33.69&73.0551',
'_mystore2_session'=>'BAh7CUkiD3Nlc3Npb25faWQGOgZFRkkiJTAxYzJhNTBkYmY3ZTRkYTBhYmY4NzhjNzdmNGY5OWRhBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMXB0WEl6NnZKSnF2ZVNCTTVXdnEzODdqWkc0cXFsN1RiTDB4d3o4WWo2aUE9BjsARkkiGXdhcmRlbi51c2VyLnVzZXIua2V5BjsAVFsISSIQU3ByZWU6OlVzZXIGOwBGWwZpAzggAUkiGXk0MTFIUTdVUktORkh2MzFCeEtFBjsARkkiCmZsYXNoBjsARm86JUFjdGlvbkRpc3BhdGNoOjpGbGFzaDo6Rmxhc2hIYXNoCToKQHVzZWRvOghTZXQGOgpAaGFzaHsHOg5hbmFseXRpY3NUOgxzdWNjZXNzVDoMQGNsb3NlZEY6DUBmbGFzaGVzewc7CnsIOg1jYXRlZ29yeUkiDENvbnRhY3QGOwBGOgthY3Rpb25JIhFsZWFkX2NhcHR1cmUGOwBGOgpsYWJlbEkiFFNlbGwgTW90b3JjeWNsZQY7AEY7C0kiLFVwbG9hZCBpbWFnZXMgdG8gYWN0aXZhdGUgeW91ciBsaXN0aW5nIQY7AEY6CUBub3cw--c3c1b5d437fd04a80dc888822811d2d4d354ae29',
'image'=>array(new CURLFile('/path/to/file.png','image/png','Screenshot (156).png'))
//and more post data here.

),
CURLOPT_HTTPHEADER=>array(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8',
'Accept-Language: en-US,en;q=0.8',
'Cache-Control: no-cache',
'Pragma: no-cache',
'Origin: myURL',
//and more headers here
),
CURLOPT_USERAGENT=>'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
));
curl_exec($ch);

note: this is NOT the complete code, it's missing a bunch of data for CURLOPT_POSTFIELD and CURLOPT_HTTPHEADER , but this should get you started