cancel
Showing results for 
Search instead for 
Did you mean: 

Getting " 400 Bad request" with REST API request "v1/readyapi/executions/{ID}/files

Occasional Contributor

Getting " 400 Bad request" with REST API request "v1/readyapi/executions/{ID}/files

I am making a request to feed excel files to running test and getting 400 bad request. Can someone help by looking at request and tell me where am i wrong?

 

I have a test executed by making a request "/v1/readyapi/executions/xml". Test is in pending state right now. I am able to check test status by "/v1/readyapi/executions/"+executionId+"/status" as well as I can see the logs by "/v1/readyapi/executions/"+executionId+"/logs".  Test is in "Pending" state because it's looking for dependencies and it's excel file. I am trying to add it by following documents, Getting 400 Bad Request. I am not able to find what is wrong with my request. Can someone please advice? 

 

 

Here is my request:

executionId = "Basic xxxxxxx"

Data = open('C:\foo.xls', 'rb')
files = {"file_name": Data}

headers = {
'access-control-allow-origin': '*',
'accept': 'application/json',
'content-type': 'multipart/form-data', #application/xml
'authorization': 'Basic xxxxxxxxxxxxx'
}
R = requests.post('http://testserver:8080/v1/readyapi/executions/'+executionId+'/files', headers=headers, params=params, files=files)
print R.content
print R

 

Here is response:

<open file 'C:\\foo.xls', mode 'rb' at 0x032C75A0>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 400 </title>
</head>
<body>
<h2>HTTP ERROR: 400</h2>
<p>Problem accessing /v1/readyapi/executions/xxxx-xxxx-xx-xx-x/files. Reason:
<pre> Bad Request</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>

<Response [400]>

 

 

New Here?
Join us and watch the welcome video:
Watch the new Interview