I'm trying to do a discord bot with the clash of clans api. But I get a weird error message. Thanks
Error Message:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>v1/clans/LYVVC9JQQ</Key><RequestId>67H6BCRSJ41W6K6X</RequestId><HostId>mPhpqkXy1qKENdOnt+CPhfQn4rK0hGhaMxaLq9q21Ehtbs/CMzSgqHy9TA6L7hii0PY9+Lo2rzg=</HostId></Error>
async function getClashofClansAPi() { let clashofClansAPI = await fetch(`https://developer.clashofclans.com/v1/clans/LYVVC9JQQ`) let cocApi = await clashofClansAPI.text() console.log(cocApi) } getClashofClansAPi()
The API URL is api.clashofclans.com
and you are also lacking an API KEY in your authorization header unless you removed it for security purposes
Clash of Clans API uses JSON Web Tokens for authorizing the requests. Tokens are created by developers on My Account page and must be passed in every API request in Authorization HTTP header using Bearer authentication scheme. Correct Authorization header looks like this: "Authorization: Bearer API_TOKEN".
The request url should be https://api.clashofclans.com/v1/clans/%232Q8GRY8LQ
Remember, the hashtag (for example #2PP) should be replaced with %23, Next time, please read Clash of Clans API Documentation correctly.
async function getClashofClansAPi() { let clashofClansAPI = await fetch(`https://developer.clashofclans.com/v1/clans/LYVVC9JQQ`) let cocApi = await clashofClansAPI.text() console.log(cocApi) } getClashofClansAPi()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.