Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Shopify Graphql Error on upload pdf file on google

Shopify Graphql Error on upload pdf file on google

antonioreale
Shopify Partner
19 1 3

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?

 

Replies 3 (3)

JermyAublc
Shopify Partner
3 0 0

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

flyingL123
Shopify Partner
4 0 3

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.

flyingL123
Shopify Partner
4 0 3

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.