cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Set User Extensions' properties via REST-API

joao_espadanal
6-Contributor

Set User Extensions' properties via REST-API

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

4 REPLIES 4

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        

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"

         }

      ]

   }

}

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)

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

Top Tags