how convert this curl request
curl request
curl -L -F 'Request={"APIRequests":
[{"Verb":"UploadModelRelease","AuthToken":"","FirstName":"John","LastName":"Smith","Gender
":"0","AgeGroup":"1","Ethnics":"0","Country":"44"}]}' -F
'PropertyRelease=@Documents/jamie.pdf' https://api2.dreamstime.com/api/
to guzzlehttp request
guzzlecode
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', "https://api2.dreamstime.com/api/",[
'json'=>[
'APIRequests' => [
[
"Verb" => "UploadRelease",
"AuthToken" => $this->getAccessToken(),//token
"ModelRelease" => $file,//file path
"FirstName" => $firstName,
"LastName" => $lastName,
"Gender" => $gender,
"Country" => $country,
"AgeGroup" => $ageGroup,
"Ethnics" => $ethnics,
],
],
]
]);
error "please upload a release file"
I have written a query closest to the curl request, as curl request has a -F with file that means that it is sending file, you will need multipart. As I have not tested so I can't guarantee that it will work though
/**
curl -L -F 'Request={"APIRequests":
[{"Verb":"UploadModelRelease","AuthToken":"","FirstName":"John","LastName":"Smith","Gender
":"0","AgeGroup":"1","Ethnics":"0","Country":"44"}]}' -F
'PropertyRelease=@Documents/jamie.pdf' https://api2.dreamstime.com/api/
*/
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', "https://api2.dreamstime.com/api/",[
'multipart' => [
[
'name' => 'Request',
'contents' => '{
"APIRequests":
[{"Verb":"UploadModelRelease","AuthToken":"","FirstName":"John","LastName":"Smith","Gender
":"0","AgeGroup":"1","Ethnics":"0","Country":"44"}]
}' // place your json_encode here inplace of above
],
[
'name' => 'PropertyRelease',
'contents' => fopen("/path/to/file", "r")
]
]
]);