Set and get Asset Type through API

Answered

Comments

3 comments

  • Official comment
    Ragnar Engnes

    Hello Christian.

    As you pointed out - it is available through the REST api, and if you want to use the client API, we have a method to call it directly. For example:

    var existingAssetTypes = mes.Asset.RESTGetJson<AssetType[]>($"api/Asset/Types?$filter=startswith(typeName, 'somePrefix')");

    Comment actions Permalink
  • Christian

    Hi Ragnar

     

    Thanks for the clarification. One follow-up question:

    If I get the assets with mes.Assets.GetAssets(""); I will not get the AssetType (alyways null). -> See below.

    What am I doing wrong? (in WATS I see all the needed data, but I am currently not able to read id through the API). Do I need another call to get the AssetType of an Asset?

     

    Thanks!

     

    0
    Comment actions Permalink
  • Ragnar Engnes

    Hi

    Correct,, you can either ask for assettype or you can use GetAsset. The type is then automatically returned in the AssetRespons.AssetObject.AssetType:

     

    0
    Comment actions Permalink

Please sign in to leave a comment.