Skip to main content
1-Visitor
September 26, 2017
Solved

Set User Extensions' properties via REST-API

  • September 26, 2017
  • 1 reply
  • 3138 views

I it possible to set new values for the User Extensions' properties of a specific user via REST-API?

We've tried invoking the SetProperties and we would get 200 OK response, but the property we were trying to update would not be updated.

Thank you.

    Best answer by joao_espadanal

    Johan Bester escreveu:

    Thank you for the feedback João, now I know for future reference.

    It is strange that my suggested method didn't work, I did test it again to make sure it works (are you sure you set it to a PUT call?), did you change the property you want to update in the URL as well as the body? otherwise it might be permissions issues if the appKey you used isn't an administrator.

    But I guess it doesn't really matter since you were able to do what you needed to do.

    I am glad if my input helped.

    (If you could mark an answer as correct to change the question's classification from "Not answered" to answered, it might help future people looking for answered questions)

    I was using POST, as soon as I've tried PUT it worked as you suggested, with a much friendlier JSON body.

    Thank you for your fast and accurate response

    1 reply

    14-Alexandrite
    September 26, 2017

    Good day João,

    I was able to set the property "firstName" using a PUT request as follows:

    http://<Server>/Thingworx/Users/<User>/Properties/firstName

    The headers (appKey, Content-Type)

    The body: {"firstName" : "test"}

    You can change the property name to the property you want to update.

    In theory, you should be able to use the SetPropertyValues service with a POST request but it seems like the input to the service is an infotable and I am not sure how the body structure of the REST call will look then.

    I hope this helps somewhat.

    Kind regards,

    Johan Bester        

    1-Visitor
    September 26, 2017

    Hello Johan!

    I've tried what you suggested, yet it didn't work... I received a 404 Bad Request.

    So I tried using SetPropertyValues and building the InfoTable. That did the :

    URL: https://<MY_TWX_SERVER>/Thingworx/Users/<MY_USER>/Services/SetPropertyValues

    BODY:

    {

       "values":{ 

          "created":1506422819087,

          "description":"",

          "name":"Infotable",

          "dataShape":{

             "fieldDefinitions":{

                "<PROPERTY_NAME>":{

                   "name":"<PROPERTY_NAME>",

                   "aspects":{

                      "isPrimaryKey":true

                   },

                   "description":"",

                   "baseType":"STRING",

                   "ordinal":0

                }

             },

             "name":"EntityList",

             "description":"Entity list"

          },

          "rows":[

             {

                "<PROPERTY_NAME>":"<PROPERTY_NEW_VAUE"

             }

          ]

       }

    }

    joao_espadanal1-VisitorAuthorAnswer
    1-Visitor
    September 26, 2017

    Johan Bester escreveu:

    Thank you for the feedback João, now I know for future reference.

    It is strange that my suggested method didn't work, I did test it again to make sure it works (are you sure you set it to a PUT call?), did you change the property you want to update in the URL as well as the body? otherwise it might be permissions issues if the appKey you used isn't an administrator.

    But I guess it doesn't really matter since you were able to do what you needed to do.

    I am glad if my input helped.

    (If you could mark an answer as correct to change the question's classification from "Not answered" to answered, it might help future people looking for answered questions)

    I was using POST, as soon as I've tried PUT it worked as you suggested, with a much friendlier JSON body.

    Thank you for your fast and accurate response