I added two assets to my jsm sandbox, and when I run the jsm asset enpoint in postman I get the two results I need, but the response is over 2000 lines long. was wondering if there was a way when call the endpoint to only return exactly what I need?
{âqlQueryâ: âobjectType = Hardware and "Asset Type" = "card reader" and county = 09 and branch = 00â}
this is the body that I am sending, would I have to change something about it to to narrow down the response?
Hello @JakeBurnette
- Which specific API endpoint are you sending the request to?
- What documentation are you referencing regarding that endpoint?
- What parameters are you including with the request and what are their values?
- When you say ânarrow down the resultsâ, narrow it down to what, specifically?
hello,
https://api.atlassian.com/jsm/assets/workspace/{workspaceId}/v{version}/object/{id}
From:
I am posting to https://api.atlassian.com/jsm/assets/workspace/{workspaceId}/v{version}/object/{id}
with {âqlQueryâ: âobjectType = Hardware and "Asset Type" = "card reader" and county = 09 and branch = 00â}
in the body,
I was hoping it would return these, and the value
and narrowing it down meaning could I just return the model numbers by getting a response as something like this:
"models":[
{
"model" : "xxx"
{,
{
"model" : "xxxx"
{
]
}
I also tried calling it using get, and passing the query into the url, but that still returns over 1600 lines.
Thank you for providing that additional information @JakeBurnette
Your question is starting to get confusing. You now say you are âpostingâ to an /object/{id} endpoint, but those endpoints donât support POST or searching with AQL, they just return values for a single object. I think youâve confused it with the Post object AQL endpoint
You say you want the endpoint to return an array of nine objects and their âvalueâ, but you provide only one example of what constitutes ânarrowing downâ for one object, so itâs not clear if you want to have this ânarrowing downâ effect occur for just that one objectâs values, or all the objects. In either case, you canât do that as each object has its own specific attributes and the API canât selectively isolate those for each object in the response. All it can do is return all the values for all the attributes for those objects that matched your AQL search to the same extent / degree.
I suggest you first start by doing some experiments. Use the AQL keywords like objectTypeId to limit the results to only a defined set of objects based on their IDs. Then set the includeAttributes parameter to false and observe the effect on the degree of detail returned.
Get the results being returned by the endpoint down to the bare minimum to meet your requirements, then, in your appâs code, extract from the JSON response only the data you need⊠and just ignore the excess.
Have fun.
thanks, Iâll try that yeah sorry I did get the endpoints mixed up. I copied and pasted the wrong one.
but to explain a little further,
I have a few of these card readers on out jsm sandbox, and Iâm querying by county and branch. All I need is the value of Model so in the example of the picture I would just need â123456â. Would the objectTypeId be static for any model number it returns, since most offices I would query would have more than one available card reader. and if it is how would know the Modelâs objectTypeId? Sorry about the confusing question, Iâm still in the beginning stages of a project at work and donât have a full grasp on it yet.
The problem you are describing is known as âover-fetchingâ and is a common, well-known problem for REST APIs. In the specific case of JSM Assets, no, there are no mechanisms in the API for obtaining only-specified attributes on an object.