I don’t know what I am doing wrong, but when I try to post to cloudflare’s API I keep on getting an error message that reads:
Request failed with status code 400
I am using axios to make the request, e.g.:
const headers = {
'X-Auth-Email': MY_EMAIL,
'X-Auth-Key': MY_KEY,
'Content-Type': 'application/json'
}
const account = MY_ACCOUNT_ID
await axios
.post(
'https://api.cloudflare.com/client/v4/zones',
{ name: 'domainexample12345.com' , account: { id: account }, jump_start: true },
{ headers: headers }
)
.then((res) => {
return res.result
})
.catch((err) => {
console.log('did not create DNS entries: ', JSON.stringify(err))
return 1
})
When I use cURL, it works fine. I have also tried using the cloudflare npm module and it just returns the same error.
I have also even tried using a token with full access and still get the same error.
I just whish cloudflare could give more insight on the error.
Any help would be appreciated. Thanks !
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Open
lorddaedra opened this issue
May 21, 2019
· 5 comments
Comments
Hi @lorddaedra , could you solve your problem? The same thing is happening to me, any idea how to solve it?
Thanks
I’ve also run into this issue — anyone found a reason why or how to solve it?
@skilledboy I am sorry to have kept you waiting for so long.
@ here
I do not use cloudflare-ingress-controller anymore. (I use Google Cloud Run service for most of my projects…)
We are currently more focused on improving the cloudflared client itself, leaving this ingress controller deprecated. You can read more here: #172 (comment)
I recently added my site to Cloudflare and all of my subdomains like portainer and my file server are working however my main domain that points to my Nginx server returns «error 400 bad request The plain HTTP request was sent to HTTPS port»
I am using caddy to reverse proxy with this config
georgenet.uk:443 {
tls internal
reverse_proxy 192.168.0.50:444
}
georgenet.uk:80 {
tls internal
reverse_proxy 192.168.0.50:81
}
and my Nginx server is using this config
server {
listen 81;
listen [::]:81;
server_name georgenet.uk www.georgenet.uk;
return 302 https://$server_name$request_uri;
}
server {
# SSL configuration
listen 444 ssl http2;
listen [::]:444 ssl http2;
ssl_certificate /etc/ssl/cert.pem;
ssl_certificate_key /etc/ssl/key.pem;
server_name georgenet.uk www.georgenet.uk;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ =404;
}
}
I have already tried ssl off
and ssl on
like many solutions have suggested however I keep getting this error, is it something to do with caddy redirecting the default ports to 81 and 444 as this was working before I started using Cloudflare.
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?
Hey @OCG,
Can I check if you’re trying to create a new contact using this endpoint Create a new contact | Contacts API and the following POST body:
{ "properties": [ { "property": "email", "value": "testingapis@hubspot.com" }, { "property": "firstname", "value": "Adrian" }, { "property": "lastname", "value": "Mott" }, { "property": "website", "value": "http://hubspot.com" }, { "property": "company", "value": "HubSpot" }, { "property": "phone", "value": "555-122-2323" }, { "property": "address", "value": "25 First Street" }, { "property": "city", "value": "Cambridge" }, { "property": "state", "value": "MA" }, { "property": "zip", "value": "02139" } ] }
on portal 719xxxx?
If so, I have managed to successfully create a contact (which I have deleted) using the above POST body on portal 719xxxx.
Additionally, are you using a hapikey/oauth token to authenticate the request?
#cloudflare
Вопрос:
Я не знаю, что я делаю неправильно, но когда я пытаюсь опубликовать в API cloudflare, я продолжаю получать сообщение об ошибке следующего содержания:
Request failed with status code 400
Я использую axios для отправки запроса, например:
const headers = {
'X-Auth-Email': MY_EMAIL,
'X-Auth-Key': MY_KEY,
'Content-Type': 'application/json'
}
const account = MY_ACCOUNT_ID
await axios
.post(
'https://api.cloudflare.com/client/v4/zones',
{ name: 'domainexample12345.com' , account: { id: account }, jump_start: true },
{ headers: headers }
)
.then((res) => {
return res.result
})
.catch((err) => {
console.log('did not create DNS entries: ', JSON.stringify(err))
return 1
})
Когда я использую завиток, он отлично работает. Я также пробовал использовать модуль cloudflare npm, и он просто возвращает ту же ошибку.
Я также даже пытался использовать токен с полным доступом и все равно получаю ту же ошибку.
Я просто хочу, чтобы cloudflare могла дать больше информации об ошибке.
Любая помощь будет признательна. Спасибо!