Hello,
I am trying to upload a csv file using REST API and Object Builder. Below is a snippet of my code (I am running it locally on my MacOS, filename is also called csv). Looking at the console, the request it is receiving is not formatted correctly.
Expected:
=> {“csv”=>
{“filename”=>“csv”,
“type”=>“application/octet-stream”,
“name”=>“csv”,
“tempfile”=>#<File:/tmp/RackMultipart20180919-23531-199aa4a>,
“head”=>“Content-Disposition: form-data; name=\“csv\”; filename=\“csv\”\r\nContent-Type: application/octet-stream\r\n”},
“delete_mode”=>false}
Actual: {“csv”=>“csv”, “delete_mode”=>false}
Any help would be appreciated…Thanks!
def builder = new RestRequestObjectBuilder()
def requestObject = builder.withRestRequestMethod(‘POST’)
.withRestUrl(GlobalVariable.SUT + “/api/preprocess_csv”)
.withHttpHeaders([
new TestObjectProperty(‘Content-Type’, ConditionType.EQUALS, ‘multipart/form-data’),
new TestObjectProperty(‘Cookie’, ConditionType.EQUALS, anpkSess.toString()),
new TestObjectProperty(‘Authorization’, ConditionType.EQUALS, ‘####’)])
.withMultipartFormDataBodyContent([
new FormDataBodyParameter(“csv”, “csv”, “PARAM_TYPE_FILE”),
new FormDataBodyParameter("csv", 'Content-Disposition: form-data; name="csv"; filename="csv"', "PARAM\_TYPE\_TEXT")
\]).build()
Resp = WS.sendRequest(requestObject)
print(Resp.getStatusCode())
print(Resp.getResponseText())
Thanks, Nanda