Hey. I am writing an HttpService API (to make things easier when I work), I am currently working on an Avatar Headshot API (I don’t like to use Roblox’s one), but it errors in the output: ‘Http 404 (Not Found)’.
This is the code that I’ve written so far:
--[[
Module.new(player) --> Self {class}
Self:GetAvatarData() --> State {boolean}, Data {table}
Self:GetFollowingsCount() --> State {boolean}, Data {integer}
Self:GetFriendsCount() --> State {boolean}, Data {integer}
Self:GetAvatarHeadshot(size) --> State {boolean}, Data {string}
--]]
local httpService = (game:GetService("HttpService"));
local httpApi = {}
httpApi.__index = httpApi
function httpApi.new(player)
assert(not (player == nil), "Argument 'player' is equal to nil.")
assert(typeof(player) == "Instance", string.format("Argument 'player' expected to be player, got %s", typeof(player)))
assert(player:IsA("Player"), "Argument 'player' is not a player.")
return setmetatable({Player = player}, httpApi)
end;
function httpApi:GetAvatarData()
local url = ("https://avatar.rprxy.xyz/v1/users/".. self.Player.UserId.. "/avatar");
return pcall(function()
local body = (httpService:JSONDecode(httpService:GetAsync(url)));
return body
end)
end;
function httpApi:GetFollowingsCount()
local url = ("https://friends.rprxy.xyz/v1/users/".. self.Player.UserId.. "/followings/count");
return pcall(function()
local body = (httpService:JSONDecode(httpService:GetAsync(url)));
return body.count
end)
end;
function httpApi:GetFriendsCount()
local url = ("https://friends.rprxy.xyz/v1/users/".. self.Player.UserId.. "/friends/count");
return pcall(function()
local body = (httpService:JSONDecode(httpService:GetAsync(url)));
return body.count
end)
end;
function httpApi:GetAvatarHeadshot(size)
assert(not (size == nil), "Argument 'size' is equal to nil.")
assert(typeof(size) == "string", string.format("Argument 'size' expected to be string, got %s", typeof(size)))
local url = ("https://thumbnails.rprxy.xyz/v1/users/".. self.Player.UserId.. "/avatar-headshot");
return pcall(function()
local body = (httpService:JSONDecode(httpService:GetAsync(url))); -- // Error here, the path is not found.
return body
end)
end;
return httpApi
The error appears in the last function in the ModuleScript. Any help would be appreciated.
Edit: Here is a link to the API source https://thumbnails.roblox.com/docs#!/Avatar/get_v1_users_avatar_headshot