Skip to main content
1-Visitor
May 20, 2018
Question

Not authorized for Property Write in thingworx

  • May 20, 2018
  • 2 replies
  • 1557 views

I am trying run a thread in a function.This function gets the data coming from the socket and assing this data into thinking property.But I get 'Not authorized for Property Write in thingworx'.I looked at the thingworx extension API Doc. But I did not find any examples about this ThreadLocalContext.Where do I make mistakes

 

public void startThread() {

		Thread t = new Thread(() -> {
			String line = "";
			try {
				SecurityContext systemContext = SecurityContext.createSystemUserContext();
				ThreadLocalContext.setSecurityContext(systemContext);
				Thing thing = ThingUtilities.findThing("AEOSEvents");
				ThreadLocalContext.clearSecurityContext();

				while ((line = reader.readLine()) != null) {
 thing.setPropertyValue("rawEvents", new StringPrimitive(line));
			}

				}
			} catch (IOException e) {
				e.printStackTrace();
			} catch (Exception e) {
				e.printStackTrace();
			}
		});
		t.start();

	}

 

2 replies

15-Moonstone
May 23, 2018

Have you checked that the permissions for the AEOSEvents Thing allow the system user to write to this rawEvents property?

keles0glu1-VisitorAuthor
1-Visitor
May 25, 2018

Yes. I have checked.Not only about permission.But i did it.I have to use TransactionFactory for multithread in thingworx.