Help using the presence API [JavaScript]

You could’ve brought this over to Stack Overflow but it’s whatever.

I just looked at the docs here

https://presence.roblox.com/docs/index.html

I don’t think userIds should be nested under ‘data’

const Options = {
   method: "POST",
   muteHTTPExeptions: true,
   userIds: [1, 516000370]
}
// etc

E

didn’t seem to work!!!

1 Like
function myFunction() {
	const url = 'https://presence.roblox.com/v1/presence/last-online';

	const options = {
		method: 'POST',
		body: JSON.stringify({
			userIds: [1383329924, 745838296],
		}),
	};

    var response = UrlFetchApp.fetch(url, options);
    var json = response.getContentText();
    console.log(json);
    var data = JSON.parse(json);
    console.log(data);
}

1 Like

2 things:

1- body should be payload
2- you have to set the Content-Type header to application/json

const options = {
    'method': 'POST',
    'payload': JSON.stringify({
       'userIds': [605492589]
    }),
    'headers': {
      'Content-Type': 'application/json',
    }
};
2 Likes

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