Cloudflare 400 error on PUT

waitman
New Member
2 0 1

 

The documentation for REST api, "Add a collect to an existing collection by providing a product ID, and update an existing collect by its own ID to change its sort position"

PUT /admin/api/2020-01/custom_collections/#{custom_collection_id}.json

 

(i don't think the # sign and anything after is going to the server, but ok let's see what happens)

 

 

> PUT /admin/api/2020-01/custom_collections/ HTTP/2
Host: shopname.myshopify.com
authorization: Basic MT..ZDc=
accept: */*
content-type: application/json
content-length: 2969

* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 400 
< server: cloudflare
< date: Wed, 01 Apr 2020 20:10:30 GMT
< content-type: text/html
< content-length: 155
< cf-ray: 57d4f437bc8393a6-SJC
* HTTP error before end of send, stop sending
< 
* Connection #0 to host shopname.myshopify.com left intact
HTTP/2 400 
server: cloudflare
date: Wed, 01 Apr 2020 20:10:30 GMT
content-type: text/html
content-length: 155
cf-ray: 57d4f437bc8393a6-SJC

<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>cloudflare</center>
</body>
</html>

 

could be HTTP/2 related. it's returning a 400 before data, so it shouldn't be a problem with the data. How does cloudflare know about the data anyway?

 

Anyone have an idea what's the problem?

 

 

0 Likes
waitman
New Member
2 0 1

It's working. I changed two things.

Remove # from URL. (not sure why it's in the documentation?)

so, I think URL should be:

PUT /admin/api/2020-01/custom_collections/{custom_collection_id}.json

 

Also, I removed curl option "CURLOPT_PUT" which I learned is deprecated. It's meant to be used to put a file anyway, so I think maybe it was not originally sending data with request. But that wasn't clear to me in the verbose output. Anyhow, correct option is CURLOPT_CUSTOMREQUEST = PUT

 

 

 

patacala72
New Member
1 0 0

La funcion  "CURLOPT_PUT" esta en deprecada ahora debe usarse CURLOPT_CUSTOMREQUEST = "PUT".   deberia quedar asi 

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
0 Likes