Problem to solve
- My javascript script for POST API call fails with the following error message (I’ve been using this script for publishing issues and there was no problem until today.):
Error Message: Request failed with status code 403
</h1>
<div class="container">
<p>You are currently viewing from a blocked IP address or country.</p>
Client IP: <MY_PUBLIC_IP>
<br>
Ray ID: xxxxxxx
<br>
Location:
<hr />
</div>
</body>
</html>
Error Message: Request failed with status code 403
Steps to reproduce
- call
node issueAPI.js
returns error code 403. - While this
curl
call successfully created an issue.
curl --request POST --header "PRIVATE-TOKEN: <MY_TOKEN>" \
--data "title=some title" \
"https://gitlab.com/api/v4/projects/<MY_PROJECT_ID>/issues"
Configuration
My script issue.API.js
const fs = require('fs');
const axios = require('axios');
const { projectId, accessToken } = require('./config');
// Read the Markdown file content
const descriptionContent = fs.readFileSync('description.md', 'utf-8');
// Define the API URL and your GitLab token
const url = `https://gitlab.com/api/v4/projects/${projectId}/issues`;
const token = accessToken;
const data = {
title: 'some title',
description: descriptionContent
};
const config = {
headers: {
'PRIVATE-TOKEN': token,
'Content-Type': 'application/json'
},
};
axios.post(url, data, config)
.then(response => {
console.log('Issue created:', response.data);
})
.catch(error => {
console.error('Error creating issue:');
console.error( 'Error Data: ', error.response.data);
console.error('Error Message: ', error.message);
});
Troubleshooting I’ve tried so far
-
I’ve double-checked my project id and token. There is no question these are correct.
-
Token scope:
api
,read_api
,read_repository
,write_repository
-
netcat OK
$ nc -vz gitlab.com 443
Connection to gitlab.com port 443 [tcp/https] succeeded!
- ping OK
$ ping gitlab.com
PING gitlab.com (172.65.251.78): 56 data bytes
64 bytes from 172.65.251.78: icmp_seq=0 ttl=55 time=3.543 ms
64 bytes from 172.65.251.78: icmp_seq=1 ttl=55 time=11.485 ms
64 bytes from 172.65.251.78: icmp_seq=2 ttl=55 time=11.243 ms
64 bytes from 172.65.251.78: icmp_seq=3 ttl=55 time=10.636 ms
64 bytes from 172.65.251.78: icmp_seq=4 ttl=55 time=11.081 ms
- tried below following this similar post
curl http://gitlab.com/cdn-cgi/trace
curl https://gitlab.com/cdn-cgi/trace
curl -svo /dev/null https://gitlab.com
Results were all successful
fl=34f272
h=gitlab.com
ip=<my_public_ip>
ts=1727595351.286
visit_scheme=https
uag=curl/8.4.0
colo=ICN
sliver=none
http=http/2
loc=KR
tls=TLSv1.3
sni=plaintext
warp=off
gateway=off
rbi=off
traceroute gitlab.com
:
traceroute gitlab.com
traceroute to gitlab.com (172.65.251.78), 64 hops max, 52 byte packets
1 10.58.56.1 (10.58.56.1) 3.030 ms 1.933 ms 2.272 ms
2 211.106.114.190 (211.106.114.190) 2.371 ms 2.875 ms 2.158 ms
3 * * *
4 * * *
5 112.189.14.97 (112.189.14.97) 10.058 ms
112.189.13.197 (112.189.13.197) 3.017 ms
112.189.14.205 (112.189.14.205) 2.746 ms
6 * * *