Is there a way to filter down the the JSM asset response?

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?
image

{“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

  1. Which specific API endpoint are you sending the request to?
  2. What documentation are you referencing regarding that endpoint?
  3. What parameters are you including with the request and what are their values?
  4. 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.

@JakeBurnette,

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.

2 Likes