Querying assets via API
Hello,
I'm trying to query the assets via the K1 API. The example in the doc (/machines?shaping=machine all,software limited&sorting=software.name desc&use_count=false&filtering=id lt 1000&paging=limit) works fine.
But I can't do the same with assets.
The doc tells to do it like :
That's the better information I can get. No query like filtering or shaping works on assets as they works on machines. Only giving the asset id works.
Do some of you succeed in querying assets ?
I'm trying to query the assets via the K1 API. The example in the doc (/machines?shaping=machine all,software limited&sorting=software.name desc&use_count=false&filtering=id lt 1000&paging=limit) works fine.
But I can't do the same with assets.
The doc tells to do it like :
GET /api/asset/assets/So I did :
https://k1000/api/asset/assets
The answer is :{I try to replace "assets" with an asset ID :
"message": "Asset with ID assets does not exist."
}
https://k1000/api/asset/22408
And then get some information about it :{
"ID": 22408,
"ASSET_TYPE_ID": 1,
"ASSET_TYPE_NAME": "Location",
"NAME": "- REPRO",
"MODIFIED": "2018-04-12 12:28:28",
"CREATED": "2018-04-12 12:28:28"
}
That's the better information I can get. No query like filtering or shaping works on assets as they works on machines. Only giving the asset id works.
Do some of you succeed in querying assets ?
1 Comment
[ + ] Show comment
Answers (1)
Answer Summary:
Please log in to answer
Posted by:
JasonEgg
6 years ago
Top Answer
In your GET header, try adding "x-dell-api-version" with a value of "8"
I was using "1" for that value and it worked for inventory queries but I received the error "API disabled" when I attempted to query assets. Changing to "8" resolved the problem and I was able to get asset data.
Comments:
-
It looks like it did the trick ! Thankyou. - gwir 6 years ago
First I authenticate :
POST /ams/shared/api/security/login HTTP/1.1
Host: k1000.univ-ubs.fr
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache
{
"password" : "apimanPass",
"userName" : "apiman",
"organizationName" : "UBS-CGP"
}
Then I'm querying the assets with the csrf token sent by the api :
GET /api/asset/assets/ HTTP/1.1
Host: k1000.univ-ubs.fr
Accept: application/json
Content-Type: application/json
x-dell-csrf-token: 3edc622125b0417b2321e1cdd2476719ec01d8cf0afa896f99c6f604e898a196409b000fef11daa7a7fa143d9c9023ebef4edfb5ca473954db8a85aef15a9a48
Cache-Control: no-cache
And I received a 404 not found...
Without the ending / the response is :
{"message": "Asset with ID assets does not exist."} - gwir 6 years ago