Creating a smart_collection using curl but getting error: Required parameter missing or invalid

Hi

Well, I’ve certainly got more information now, although I have to confess it doesn’t mean much to me - here’s the full transcript (with anything sensitive removed):

C:\Users\{Username}>curl -v -d '{"smart_collection":{"title":"Accounting","rules":[{"column":"tag","relation":"equals","condition":"Accounting"}]}}' -X POST "https://{my-website}.myshopify.com/admin/api/2021-10/smart_collections.json" -H "X-Shopify-Access-Token: {API-Password}"  -H "Content-Type: application/json" -H "x-request-id: cutcliffe-smart_collection-issue"
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 23.227.38.74...
* TCP_NODELAY set
* Connected to {my-website}.myshopify.com (23.227.38.74) port 443 (#0)
* schannel: SSL/TLS connection with {my-website}.myshopify.com port 443 (step 1/3)
* schannel: checking server certificate revocation
* schannel: sending initial handshake data: sending 199 bytes...
* schannel: sent initial handshake data: sent 199 bytes
* schannel: SSL/TLS connection with {my-website}.myshopify.com port 443 (step 2/3)
* schannel: failed to receive handshake, need more data
* schannel: SSL/TLS connection with {my-website}.myshopify.com port 443 (step 2/3)
* schannel: encrypted data got 2846
* schannel: encrypted data buffer: offset 2846 length 4096
* schannel: sending next handshake data: sending 93 bytes...
* schannel: SSL/TLS connection with {my-website}.myshopify.com port 443 (step 2/3)
* schannel: encrypted data got 258
* schannel: encrypted data buffer: offset 258 length 4096
* schannel: SSL/TLS handshake complete
* schannel: SSL/TLS connection with {my-website}.myshopify.com port 443 (step 3/3)
* schannel: stored credential handle in session cache
> POST /admin/api/2021-10/smart_collections.json HTTP/1.1
> Host: {my-website}.myshopify.com
> User-Agent: curl/7.55.1
> Accept: */*
> X-Shopify-Access-Token: {API-Password}
> Content-Type: application/json
> x-request-id: cutcliffe-smart_collection-issue
> Content-Length: 97
>
* upload completely sent off: 97 out of 97 bytes
* schannel: client wants to read 102400 bytes
* schannel: encdata_buffer resized 103424
* schannel: encrypted data buffer: offset 0 length 103424
* schannel: encrypted data got 876
* schannel: encrypted data buffer: offset 876 length 103424
* schannel: decrypted data length: 813
* schannel: decrypted data added: 813
* schannel: decrypted data cached: offset 813 length 102400
* schannel: encrypted data length: 34
* schannel: encrypted data cached: offset 34 length 103424
* schannel: decrypted data length: 5
* schannel: decrypted data added: 5
* schannel: decrypted data cached: offset 818 length 102400
* schannel: encrypted data buffer: offset 0 length 103424
* schannel: decrypted data buffer: offset 818 length 102400
* schannel: schannel_recv cleanup
* schannel: decrypted data returned 818
* schannel: decrypted data buffer: offset 0 length 102400
< HTTP/1.1 400 Bad Request
< Date: Wed, 10 Nov 2021 14:47:05 GMT
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Sorting-Hat-PodId: 162
< X-Sorting-Hat-ShopId: 40312733859
< X-Shopify-Stage: production
< Content-Security-Policy: frame-ancestors 'none'
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Permitted-Cross-Domain-Policies: none
< X-XSS-Protection: 1; mode=block
< X-Dc: gcp-europe-west1,gcp-us-east1,gcp-us-east1
< X-Request-ID: 12772b2f-419b-4ceb-ab7c-6827584ab785
< CF-Cache-Status: DYNAMIC
< Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< Server: cloudflare
< CF-RAY: 6ac012ef89e675a9-LHR
< alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400
<
Bad Request* Connection #0 to host {my-website}.myshopify.com left intact

C:\Users\{Username}>

Is anyone able to assist with working out why this command fails?

It mentions that I don’t need the -x switch as POST is already inferred, although it doesn’t work if I take that switch out as it says there’s no URL. There’s also something about a handshake failing, and needing more data, but I’ve got no idea what it means, and I think my command is very similar to the example in the documentation, or at least it will be once you add the requirement for the -H “Content-Type: application/json” header.

Thanks,

Paul Cutcliffe