eeight
December 9, 2021, 2:05pm
1
Hi,
I am using the REST API to fetch all records from Human, before I was using a python script that did something like this:
humanAllFields = sg.schema_field_read("HumanUser").keys()
sg.find("HumanUser", filters=[], fields=humanAllFields)
I was getting all the fields including the multi-entity ones. Now using the REST API, I don’t get the multi-entity field even if I try to specify it. Any pointers?
sichoi
December 17, 2021, 12:05am
3
If you want the values of all fields through REST API, you just need to enter “*” as the values of fields.
function sg_find(entity, conditions, comflex=false, page=false){
var result = null;
var headers = {
'Content-Type':'application/vnd+shotgun.api3_array+json',
'Accept':'application/json',
'Authorization': `Bearer ${access_token}`
};
if( comflex ){
headers['Content-Type'] = 'application/vnd+shotgun.api3_hash+json'
}
if( page ){
conditions['page'] = page
}
$.ajax({
url: `${site_url}/api/v1/entity/${entity}/_search`,
method: 'POST',
headers: headers,
data: JSON.stringify(conditions),
async : false,
success: function(data) {
result = data.data
}
})
return result;
}
data = { "filters" : [], "fields" : "*" }
users = sg_find( 'human_users', data )
console.log( users )
And, the results of the multi-entity fields are contained in the relationships, not attributes.
1 Like
eeight
December 17, 2021, 1:42pm
4
@sichoi Thank you very much for the sharing your implementation and even providing the screenshot. I own you one