Your solution for get a list of all attribute is correct. as Guido told it is Schema Name.
i test your code and add some line off Codes for create a list off all attribute:
ODataPath = GetServerUrl() + "/XRMServices/2011/OrganizationData.svc";
var retrieveRecordsReq = new XMLHttpRequest();
var url = "";
if (entityname == 'account')
url = "/AccountSet(guid'" + guid + "')";
else if (entityname == 'contact')
url = "/ContactSet(guid'" + guid + "')";
else if (entityname == 'lead')
url = "/LeadSet(guid'" + guid + "')";
else if (entityname == 'systemuser')
url = "/SystemUserSet(guid'" + guid + "')";
retrieveRecordsReq.open('GET', ODataPath + url, false);
retrieveRecordsReq.setRequestHeader("Accept", "application/json");
retrieveRecordsReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
retrieveRecordsReq.send();
var entity = JSON.parse(retrieveRecordsReq.responseText).d;
var AllContactFields = new Array();
for(var x in entity)
{
if (typeof entity[x] == 'object') {
if (entity[x] == null)
AllContactFields.push(x);
}
else {
AllContactFields.push(x);
}
}
the AllContactFields
array is the result list.
Good Luck