AnsweredAssumed Answered

Upload to cloud works, but fails on local server

Question asked by Chris4fe7bd77-3d5d-418a-be02-909662e4ce8d on Sep 26, 2017
Latest reply on Sep 30, 2017 by Javier Padilla

Hi there,

I am trying to communicate with the Thread Prevention API using a C# client. Got a test API key for the cloud, but in the end, I want to use our local system. On the cloud everythin works fine. But on the local system, the upload fails: code:1008,label:BAD_REQUEST, message: Invalid Multipart/form request. I compared the requests using fiddler, they seem to be the same. Something like

 

POST https://te.checkpoint.com/tecloud/api/v1/file/upload HTTP/1.1
Authorization: TE_API_KEY_n7xxxxxxxxxxxxxxxxxxxxxxxxxxxuP
Content-Type: multipart/form-data; boundary="Upload----09/26/2017 10:31:22"
Host: te.checkpoint.com
Cookie: te_cookie=AOPHKIXA
Content-Length: 23060
Expect: 100-continue

--Upload----09/26/2017 10:31:22
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=request

{"request":{"extraction":{"scrubbed_parts_codes":null,"method":null},"file_type":"pdf","file_name":"Test.pdf","te":{"images":null,"reports":[]},"features":["te"],"sha1":"314e2eda1b4d26c060ec49c0db11ce1eefc8ee55"}}
--Upload----09/26/2017 10:31:22
Content-Disposition: form-data; name=file; filename=Test.pdf; filename*=utf-8''Test.pdf

%PDF-1.5 .......

 

The C# upload code sniplet looks like this:

 

using (var formData = new MultipartFormDataContent("Upload----1234567457645"))
{
formData.Add(stringContent, "request");
formData.Add(fileStreamContent, "file");
var response = client.PostAsync(new Uri(TE_API_URL + UPLOAD_PATH), formData).Result;
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadAsStringAsync();
}
}
return null;

 

Does anybody have an idea what is going wrong locally? 

Outcomes