Request-friendship api endpoint recieves status code 500 no matter what

I’m trying to make a simple python program that scans your current friends and if it notices that somebody unfriended you, it resends them a friend request. I’ve made a similar working prototype before a few years ago, but recently it seems the API has been having some issues.

The endpoint “https://friends.roblox.com/v1/contacts/{userId}/request-friendship” (use the POST method for this) ALWAYS responds with an error code 500 unless it’s directly from the roblox website/application itself.
Both my python program and the API documentation on it responds with status code 500.


Alongside this, my python program’s output.

Here’s the code in question. I’ve tried adding referrers, content types, checking to make sure the X-CSRF token is valid, include friendshipOriginSources etc.

import requests

def RobloxEndpointRequest(method, url, **kwargs):
    session = requests.Session()
    session.cookies[".ROBLOSECURITY"] = "not_sharing_with_others_lol"
    request = session.request(method, url, **kwargs)
    if "X-CSRF-TOKEN" in request.headers:
        session.headers["X-CSRF-TOKEN"] = request.headers["X-CSRF-TOKEN"]
        response = session.request(method.lower(), url, **kwargs)
        return response
    else:
        return False

stat = RobloxEndpointRequest("POST", "https://friends.roblox.com/v1/contacts/16/request-friendship", headers={'Content-Type':'application/json', 'Referer':'roblox.com'}, data={'friendshipOriginSourceType':0})
print("endpoint responded with code", stat.status_code)

Is this an issue with Roblox itself, my own network, or has Roblox restricted this api endpoint from being used outside their own website/application?
Any help is greatly appreciated.

/v1/contacts/{targetContactId}/request-friendship is not for requesting friendship with a user ID, it is for requesting friendship with a contact (UUID format) from the user’s phone. Please use /v1/users/{userId}/request-friendship instead.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.