Skip to main content
14-Alexandrite
August 9, 2021
Solved

error executing getjson() service

  • August 9, 2021
  • 1 reply
  • 2712 views

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() :-

122_0-1628506134493.png

please help me to solve this error....i need the output in below format:-

 
 
 
 
 

122_7-1628506546403.png

 

 

 

 

 

 

Best answer by PaiChung

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?

1 reply

PaiChung22-Sapphire IAnswer
22-Sapphire I
August 9, 2021

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?

Ru_0114-AlexandriteAuthor
14-Alexandrite
August 10, 2021

@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

122_1-1628601538456.png

 

Postjson() service error

122_0-1628600521301.png

 

 

22-Sapphire I
August 10, 2021

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.