Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Hello! I've been learning how to work with the REST API in Thingworx. For the most part, it's been relatively easy, but working with InfoTables has been a pain. I've been aiming to try to edit an InfoTable, but it's not been going so well. I've tried multiple variations on formatting, but even sending back the exact same JSON as I received from the GET request failed with a 400 error code (Invalid Invocation Request), saying the query below, which is what I'm attempting to send, is not formatted correctly. I've also tried this same exact query just without the "{testInfoTable: XXX}" as well with the same error. Is there some ordering issue I'm having? I've checked with a JSON parser, and I know for sure it's valid JSON, but for whatever reason, doing a POST with this exact query doesn't work. And again, to be clear, this is the exact output I get when do a GET on this exact table. Likewise, any edits have also failed. I've done this in reference to the image I found within PTC documentation (attached). Can anyone give clarity? Thanks in advance!
{"testInfoTable":{"rows":[{"Fizz":1234,"CatFish":true,"Salmon":"Fishy"},{"Fizz":9876,"CatFish":true,"Salmon":"Castle"}],"dataShape":{"fieldDefinitions":{"Fizz":{"name":"Fizz","aspects":{"isPrimaryKey":false},"description":"","baseType":"INTEGER","ordinal":1},"CatFish":{"name":"CatFish","aspects":{"isPrimaryKey":false},"description":"","baseType":"BOOLEAN","ordinal":3},"Salmon":{"name":"Salmon","aspects":{"isPrimaryKey":false},"description":"","baseType":"STRING","ordinal":2}}}}}
Solved! Go to Solution.
I've realized my mistake after searching for longer than I'd like to admit. I shouldn't be using POST requests to edit the infoTable. I should be using PUT. Basic mistake...
I've realized my mistake after searching for longer than I'd like to admit. I shouldn't be using POST requests to edit the infoTable. I should be using PUT. Basic mistake...
I see there you're using a direct PUT to update the property - which indeed is the most direct action you can undertake to update Thing Properties.
Though I would like to add that in many cases, especially if you update this data from an external system, it would be great to use a Service as a "proxy" for this type of the operation. With this approach you can now rename your Property, perform server-side validation before setting the property, pre-process the property before setting it and more.
Hope it helps.