-1
Curl을 사용하여 파일 업로드 REST API를 호출하려고하지만 빈 화면이 반환됩니다. 잘못된 점을 알고 있습니다. 파일 업로드 API 성공하면 파일 이름을 반환합니다. 우편 배달부 도구를 사용하여 fule 업로드 나머지 API를 호출 할 수있는 것과 동일한 것.CURL Fileupload REST API
오류 :
{
"Message": "An error has occurred.",
"ExceptionMessage": "Sequence contains no matching element",
"ExceptionType": "System.InvalidOperationException",
"StackTrace": " at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)\r\n at PharmaRackv2.WebUI.Areas.Admin.Controllers.UploadController.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.d__3`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"
}
PHP 코드 : 그것은 잘 작동
try {
$file = "D:\xampp\htdocs\api.pharmarack.com\distributors\11380\08122017123602.zip";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://test.com/api/upload",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'attachment' => curl_file_create($file),
),
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: multipart/form-data",
"distributorcode: 1HUBH",
"foldername: 1HUBH"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
} catch (Exception $e) {
echo 'Message: ' . $e->getMessage();
}
우체부 CALL. 파일 업로드 API가 성공하면 파일 이름을 반환합니다.