Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
hello,
i have converted infotable data in json data by using tojson() snippet. now i want to get that data in json format by using getjson() snippet but it got the blank data...please refer below attachment
below is the getjson() code:-
var params1 = {
proxyScheme: undefined /* STRING {"defaultValue":"http"} */,
ignoreSSLErrors: true /* BOOLEAN */,
headers : undefined,
useNTLM: undefined /* BOOLEAN {"defaultValue":false} */,
workstation: undefined /* STRING {"defaultValue":""} */,
useProxy: undefined /* BOOLEAN {"defaultValue":false} */,
withCookies: undefined /* BOOLEAN {"defaultValue":false} */,
proxyHost: undefined /* STRING {"defaultValue":""} */,
url: "http://{IP}:{Port}/Thingworx/Things/digitalTwinThing/Services/getallDataRefiner1" /* STRING */,
timeout: undefined /* NUMBER {"defaultValue":60} */,
proxyPort: undefined /* INTEGER {"defaultValue":8080} */,
password: undefined /* STRING */,
domain: undefined /* STRING {"defaultValue":""} */,
username: undefined /* STRING */
};
// result: JSON
var result = Resources["ContentLoaderFunctions"].GetJSON(params1);
below is the ouput of getjson() :-
please help me to solve this error....i need the output in below format:-
Solved! Go to Solution.
Since it is a service you are calling, you'll have to use the POSTJson service vs. GET
How come you aren't calling the service directly btw, but using a REST call?
Since it is a service you are calling, you'll have to use the POSTJson service vs. GET
How come you aren't calling the service directly btw, but using a REST call?
@PaiChung as you say i have to call postjson() service from snippet and have called it but it's giving me 500 internal server error......i converted infotable data into json format by using tojson() snippet and when i am set output as json base type it's giving me an output in infotable format but when i am setting an output in text base type then it's giving me an output in json format......now i want data in json format after converting it into json format......from all these i want to create get api for postman.....so please suggest the solution on this asap....below are some attachments for your better understandings...
infotable data which i want to convert into json format
Postjson() service error
You will always have to use a POST btw since it is a service execution vs. just an in memory read of values.
I can't quite say for sure exactly what you are trying to do or what is going wrong.
the ToJSON generally only works if there is a known datashape with the table, so I'm not sure if you are created the infotable with a DataShape as its base or not.
Else, just generating an InfoTable and setting the output as JSON ... may work.
@PaiChung as you say i would have use postjson.....i used it and set output base type as json but it's giving me an error 500 internal server....... so i want to ask you that how i resolve this error?
below is my postjson() code and it's output:-
let params = {
proxyScheme: undefined /* STRING {"defaultValue":"http"} */,
headers: undefined /* JSON */,
ignoreSSLErrors: undefined /* BOOLEAN */,
useNTLM: undefined /* BOOLEAN {"defaultValue":false} */,
workstation: undefined /* STRING {"defaultValue":""} */,
useProxy: undefined /* BOOLEAN {"defaultValue":false} */,
withCookies: undefined /* BOOLEAN {"defaultValue":false} */,
proxyHost: undefined /* STRING {"defaultValue":""} */,
url: "http://localhost/Thingworx/Things/digitalTwinThing/Services/abc" /* STRING */,
content: undefined /* JSON */,
timeout: undefined /* NUMBER {"defaultValue":60} */,
proxyPort: undefined /* INTEGER {"defaultValue":8080} */,
password: "abc@123456789" /* STRING */,
domain: undefined /* STRING {"defaultValue":""} */,
username: "abc" /* STRING */
};
// result: JSON
let result = Resources["ContentLoaderFunctions"].PostJSON(params);
Please check the Script and Application Log it may have more information on the error.
i can't see any error in application log
Unfortunately Error 500 is a bit hard to interpret without any extra information.
You can try simplifying your service perhaps and go step by step until it breaks.