cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

error executing getjson() service

Ru
14-Alexandrite
14-Alexandrite

error executing getjson() service

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

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaiChung
22-Sapphire I
(To:Ru)

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?

View solution in original post

7 REPLIES 7
PaiChung
22-Sapphire I
(To:Ru)

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
14-Alexandrite
14-Alexandrite
(To:PaiChung)

@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

 

 

PaiChung
22-Sapphire I
(To:Ru)

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.

Ru
14-Alexandrite
14-Alexandrite
(To:PaiChung)

@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);

 

 

122_0-1628603260836.png

 

PaiChung
22-Sapphire I
(To:Ru)

Please check the Script and Application Log it may have more information on the error.

Ru
14-Alexandrite
14-Alexandrite
(To:PaiChung)

i can't see any error in application log

PaiChung
22-Sapphire I
(To:Ru)

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.

Top Tags