Ive tried using multiple types of request, i sat for like 2h.. All endpoitns for d1 works except

Ive tried using multiple types of request, i sat for like 2h..
All endpoitns for d1 works except query/raw
Also, note that the queries worked when running d1 locally.

You can see how the request is formed here(line 147):
https://github.com/hlpmenu/cloudflare-cli/blob/test/cf_api/D1.go#L147

Also added comments for other methods used. The isValidSql() function creates a sqlite db file and tries the query against it beforehand, which has 0 issues.
The db id, and account id is used for all requests, which means its not possible theres where the issue lies

Tried:
Using curl and go:
- Auth using api key and api token + created a new token.

- Sending the demo requests from the rest docs,

- Created a new d1 db to make sure it wasent a temporary bug.

- Tried to construct the json request manually in go, reading from a file, logged the query and request, used a json string, unescaped it, escaped it, different quote types, trimmed any potential whitespace.

- For id, which it complains about, removed the "-"

Curl:(copied from terminal now, so the format is a bit messed up, but you get the gest of it)
curl -X POST "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/d1/database/$DB_ID/raw" \ -H "X-Auth-Key: $CLOUDFLARE_API_KEY" \
-H "X-Auth-Email: $CLOUDFLARE_ACCOUNT_EMAIL" \
-H "Content-Type: application/json" \
--data '{"sql":"SELECT email FROM users;"}'

Wrangler with --command:
~/D/gem1 (production)> wrangler d1 execute $DB_NAME --command "SELECT * FROM *;" --remote

⛅️ wrangler 3.62.0
-------------------


[ERROR] Couldn't find DB with name '[REDACTED]'


Wrangler with file:
Dont have the output but it was a generic error message.
GitHub
An interactive CLI for managing Cloudflare wokers, pages, D1, R2 and more! - hlpmenu/cloudflare-cli
cloudflare-cli/cf_api/D1.go at test · hlpmenu/cloudflare-cli
Was this page helpful?