A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello, I am trying to upload a file with graphql stagedUploadsCreate.
The graphql request is fine, I am getting all the parameters, but when I post on stage url I am getting from google this error:
<?xml version='1.0' encoding='UTF-8'?><Error><Code>InvalidArgument</Code><Message>Invalid argument.</Message><Details>Cannot create buckets using a POST.</Details></Error>
I am passing the resulting parameters as pairs key, value.
What is the right way to upload a file document pdf?
Hello,
I'm facing the same issue ! (is it working with curl command but it's not working with an PHP call (HTTP facade from Laravel))
Did you find the solution ?
Thank you
Thank you
After lots of trial and error I was able to get this working properly. The trick was to use the 'attach' method on the HTTP facade.
$data = [];
foreach (Arr::get($targetResponse, 'data.stagedUploadsCreate.stagedTargets.0.parameters') as $param) {
$data[$param['name']] = $param['value'];
}
$uploadResponse = Http::attach('file', file_get_contents($localFileName))
->post(
Arr::get($targetResponse, 'data.stagedUploadsCreate.stagedTargets.0.url'),
$data
);
For me, this results in a successful file upload.
After lots of trial and error I was able to get this working properly. The trick was to use the 'attach' method on the HTTP facade.
$data = [];
foreach (Arr::get($targetResponse, 'data.stagedUploadsCreate.stagedTargets.0.parameters') as $param) {
$data[$param['name']] = $param['value'];
}
$uploadResponse = Http::attach('file', file_get_contents($localFileName))
->post(
Arr::get($targetResponse, 'data.stagedUploadsCreate.stagedTargets.0.url'),
$data
);
For me, this results in a successful file upload.