Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Kapua » Using the Device Asset Write Rest API(Trying to update the value of a channel using the RestAPI)
Using the Device Asset Write Rest API [message #1815018] Tue, 24 September 2019 09:34 Go to next message
Patrick Sernetz is currently offline Patrick SernetzFriend
Messages: 1
Registered: September 2019
Junior Member
I am currently working on an UI for Kapua to resemble the user experience from another project we┬┤ve did early this year. While doing so, I am failing in writing to an asset channel using the endpoint `v1/_/devices/AgE72ry2B3c/assets/_write`. The body I am sending looks like this:

{
  "assets": [
    {
      "name": "Display",
      "channels": [
        {
          "mode": "WRITE",
          "name": "Segment",
          "value": {}
        }
      ]
    }
  ]
}


and I receive the following response:

{
  "type": "kapuaExceptionInfo",
  "httpErrorCode": 500,
  "message": "Error: BAD_REQUEST, Generic Error - BAD_REQUEST: {1}, org.eclipse.kura.KuraException: Generic Error - BAD_REQUEST: {1}\n\tat org.eclipse.kura.internal.asset.cloudlet.AssetCloudlet.write(AssetCloudlet.java:305)\n\tat org.eclipse.kura.internal.asset.cloudlet.AssetCloudlet.doExec(AssetCloudlet.java:206)\n\tat org.eclipse.kura.core.cloud.MessageHandlerCallable.call(MessageHandlerCallable.java:139)\n\tat org.eclipse.kura.core.cloud.MessageHandlerCallable.call(MessageHandlerCallable.java:1)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n, [Ljava.lang.Object;@32dc4f51",
  "kapuaErrorCode": "ASSET_WRITE_ERROR"
}


Maybe someone did the same and found a solution...
Re: Using the Device Asset Write Rest API [message #1817222 is a reply to message #1815018] Mon, 18 November 2019 16:21 Go to previous message
Pedro de Arquer is currently offline Pedro de ArquerFriend
Messages: 34
Registered: December 2018
Member
According to @lorthirk in gitter, to write an asset the format of the body should be:

{
  "type": "deviceAssets",
  "deviceAsset": [
    {
      "name": "asset2",
      "channels": [
        {
          "valueType": "integer",
          "value": 5,
          "name": "Channel-1"
        },
        {
          "valueType": "integer",
          "value": 8,
          "name": "Channel-3"
        }
      ]
    }
  ]
}


Hope it helps!

Pedro
Previous Topic:Batch jobs fails on second execution
Next Topic:What are the limitations?
Goto Forum:
  


Current Time: Tue Feb 25 14:01:32 GMT 2020

Powered by FUDForum. Page generated in 0.06614 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top