I'm working on sending a file to an api endpoint that is giving me the following curl example to post.
curl -X POST -H "Authorization: ACCESS_TOKEN" -H "Content-Type: multipart/form-data" -F "file=@submission.zip" api_url
This is the code I'm using - prior to this I'm getting a successful authentication response but a 500 response from this.
$file = fopen('C:\\Users\\username\\Desktop\\api\\' . $fileName, 'r');
return $this->client->request(
'POST',
'api_url', [
'headers'=>[
'Authorization'=>$accessToken,
'Content-Type'=> 'multipart/form-data'
],
'body'=>[
'file'=> $file
]
]
);
I'm not sure what else I'm missing here. Any suggestions are appreciated.