Setting a number using REST error

I have had this working and I have no idea what I have done to break it, I am a fiddler so I have no doubt I have done something… I have been trying to add persistence to my setup so could be I have caused some damage there???

I set a target temperture, in a Number item called LR_Tgt_Temp it is declared like so:

Number LR_Tgt_Temp "Livingroom Thermostat Target Temperature" (gLivingroomThermostat) [ "TargetTemperature" ]

I was having issue with a maths part of the rules and after investigation I realised that the target had been set as NULL somewhere. I figured I would simply set it to a value for now and worry about why it got set to NULL later when I have more time.
I used the REST interface here is a GET:

{
  "link": "http://qtpi:8080/rest/items/LR_Tgt_Temp",
  "state": "NULL",
  "type": "Number",
  "name": "LR_Tgt_Temp",
  "label": "Livingroom Thermostat Target Temperature",
  "tags": [
    "TargetTemperature"
  ],
  "groupNames": [
    "gLivingroomThermostat"
  ]
}

And here is the unexpected result of a PUT; I was trying to put 19 as the value

{
  "error": {
    "message": "java.lang.IllegalStateException: Expected BEGIN_OBJECT but was NUMBER at line 1 column 3 path $",
    "http-code": 500,
    "exception": {
      "class": "com.google.gson.JsonSyntaxException",
      "message": "java.lang.IllegalStateException: Expected BEGIN_OBJECT but was NUMBER at line 1 column 3 path $",
      "localized-message": "java.lang.IllegalStateException: Expected BEGIN_OBJECT but was NUMBER at line 1 column 3 path $",
      "cause": "java.lang.IllegalStateException"
    }
  }
}

Any help appreciated.

Paul

Seems like your JSON was malformatted in the put you sent. What did you send?

Realised the issue.

For anyone falling foul of this, I should have used POST not PUT.

I still have to work through a persistence issue, and have no idea why thongs suddenly go to NULL but thats for another time.

Thanks

Paul

Without persistence, when OH first starts and when OH detects a change to and reloads your .items files, it reinitializes all Items to NULL which indicates the Item is uninitialized. They are suddenly going to NULL probably because you ae editing .items files.

Persistence with restoreOnStartup will instead initialize your Items to their last saved state.