I'm new to C# and Refit and I encountered an issue I can't solve. I need to convert the following CURL request to Refit (It must be refit)
curl -X 'POST' \
'https://www.hybrid-analysis.com/api/v2/quick-scan/file' \
-H 'accept: application/json' \
-H 'user-agent: Mozilla 5.0' \
-H 'api-key: p36a6qk6119e21dfxf2repsy918df0b2mt5cifpra922df944eg2iim292b1f961' \
-H 'Content-Type: multipart/form-data' \
-F 'scan_type=all' \
-F 'file=@Ziv.pdf;type=application/pdf'
The error I get each time:
"{"validation_errors":[{"field":"scan_type","errors":["This value should not be blank."]},{"field":"file","errors":["This value should not be blank."]}],"message":"Input data validation has failed. Please check 'validation_errors' field to get more data."}"
Main code: (The headers are correct for sure)
IHybridAnalysisAPIClient hybrid_analysis_client = BuilderAndServiceHybridAnalysis.GetHybridAnalysisAPIClient();
// Request Headers 2
var hybrid_analysis_upload_file_api_headers = new Dictionary<string, string>
{
{"api-key", "p36a6qk6119e21dfxf2repsy918df0b2mt5cifpra922df944eg2iim292b1f961"},
{"Accept", "application/json"},
{"User-Agent", "Mozilla 5.0"},
{"Content-Type", "multipart/form-data"}
};
byte[] readText = File.ReadAllBytes(@"C:\Users\ariels\Downloads\Ziv.pdf");
ByteArrayPart file_bytes = new ByteArrayPart(readText, @"C:\Users\ariels\Downloads\Ziv.pdf");
var response = await hybrid_analysis_client.UploadFile(hybrid_analysis_upload_file_api_headers, "all", file_bytes);
Interface:
[Multipart]
[Post("/api/v2/quick-scan/file")]
Task<Root4> UploadFile([HeaderCollection] IDictionary<string, string> headers,
[AliasAs("scan_type")] string scan_type,
[AliasAs("file")] IEnumerable<ByteArrayPart> file);
Feel free to use the API key, it was created for U guys.