3 Replies Latest reply on Aug 1, 2016 10:33 AM by Sajid Patel RSS
    rhodson Explorer

    How to create things via remote sdk

    I want my new remote thing (which uses the tw-c-sdk) to appear on the Thingworx server automatically.

         The device has a (non-admin) customer key- and it should appear in the appropriate account.

     

    These are the steps

    1-The device connects to Thingworx

    2-It attempts twApi_PushProperties

         twApi_PushProperties fails and returns an TW_INTERNAL_SERVER_ERROR result    

    (Question # 1 is there a more specific way to respond to the Thing doesn't exist error - The trace reason explains that the Thing entity is unbound - but all I get is a simple number?)

     

    I have a Thing (HEDCommissionThing) created with a Service call CreateHEDEntity I pass it a name, and it calls Resources["EntityServices"].CreateThing(params)

    - I know this works, because it creates the Thing on the server if I execute it from within Thingworx Composer

     

    3-When I receive the TW_INTERNAL_SERVER_ERROR from above I call the service using :

    twApi_InvokeService(TW_THING, "HEDCommissionThing", "CreateHEDEntity", it, &result, -1, FALSE);

     

    It fails with the following (From the TRACE):

    Reason: Unable to dispatch [ uri = /Things/HEDCommissionThing/Services/CreateHEDEntity/]: Unable to Invoke Service CreateHEDEntity on HEDCommissionThing : Execution error in service script [HEDCommissionThing CreateHEDEntity] : Wrapped com.thingworx.common.exceptions.InvalidRequestException: Not authorized for ServiceInvoke on CreateThing in EntityServices Cause: Not authorized for ServiceInvoke on CreateThing in EntityServices

     

    I have added the user with full run-time and design permission to HEDCommissionThing and to its Template   There isn't a way to add it to EntityServices (not that I have found anyways).

     

    (Question # 2 What am I doing wrong, or is there a better approach?)


    I really want the newly created object to be assigned to the correct Customer