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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

getJSON only returning headers

kyetzer
12-Amethyst

getJSON only returning headers

I have created a servlet that returns the following JSON object:

 

{"isCompressed":true,"dataShape":{"fieldDefinitions":{ "ProdLineTable":{"name":"ProdLineTable","description":"","baseType":"INFOTABLE","ordinal":1,"alias":"_0","aspects": {"dataShape":"DocUpload_ProdLineDatashape_geIntegratedDiscreteExecution"}}, "SerialNumberTable":{"name":"SerialNumberTable","description":"","baseType":"INFOTABLE","ordinal":2,"alias":"_1","aspects": {"dataShape":"DocUpload_SerialNumbersDatashape_geIntegratedDiscreteExecution"}}, "OperationTable":{"name":"OperationTable","description":"","baseType":"INFOTABLE","ordinal":3,"alias":"_2","aspects": {"dataShape":"DocUpload_OperationDatashape_geIntegratedDiscreteExecution"}}, "StepTable":{"name":"StepTable","description":"","baseType":"INFOTABLE","ordinal":4,"alias":"_3","aspects": {"dataShape":"DocUpload_StepDatashape_geIntegratedDiscreteExecution"}}}},"rows":[{"_0":{"dataShape":{"fieldDefinitions":{"WOS95ID":{"name":"WOS95ID","description":"WOS95ID","baseType":"STRING","ordinal":0,"aspects":{}},"ProductionLine":{"name":"ProductionLine","description":"ProductionLine","baseType":"STRING","ordinal":1,"aspects":{}},"ProducedMaterial":{"name":"ProducedMaterial","description":"ProducedMaterial","baseType":"STRING","ordinal":2,"aspects":{}}}},"rows":[{"WOS95ID":"40824748","ProductionLine":"BucketRepair","ProducedMaterial":"114L5352G0097"}]},"_1":{"dataShape":{"fieldDefinitions":{"Serialnumbers":{"name":"Serialnumbers","description":"Serialnumbers","baseType":"STRING","ordinal":0,"aspects":{}},"WOS95Id":{"name":"WOS95Id","description":"WOS95Id","baseType":"STRING","ordinal":1,"aspects":{}}}},"rows":[{"Serialnumbers":"","WOS95Id":""},{"Serialnumbers":"411832-001","WOS95Id":"40824748"},{"Serialnumbers":"411832-002","WOS95Id":"40824748"},{"Serialnumbers":"411832-003","WOS95Id":"40824748"},{"Serialnumbers":"411832-004","WOS95Id":"40824748"},{"Serialnumbers":"411832-005","WOS95Id":"40824748"},{"Serialnumbers":"411832-006","WOS95Id":"40824748"},{"Serialnumbers":"411832-007","WOS95Id":"40824748"},{"Serialnumbers":"411832-008","WOS95Id":"40824748"},{"Serialnumbers":"411832-009","WOS95Id":"40824748"},{"Serialnumbers":"411832-010","WOS95Id":"40824748"},{"Serialnumbers":"411832-011","WOS95Id":"40824748"},{"Serialnumbers":"411832-012","WOS95Id":"40824748"},{"Serialnumbers":"411832-013","WOS95Id":"40824748"},{"Serialnumbers":"411832-014","WOS95Id":"40824748"},{"Serialnumbers":"411832-015","WOS95Id":"40824748"},{"Serialnumbers":"411832-016","WOS95Id":"40824748"},{"Serialnumbers":"411832-017","WOS95Id":"40824748"},{"Serialnumbers":"411832-018","WOS95Id":"40824748"},{"Serialnumbers":"411832-019","WOS95Id":"40824748"},{"Serialnumbers":"411832-020","WOS95Id":"40824748"},{"Serialnumbers":"411832-021","WOS95Id":"40824748"},{"Serialnumbers":"411832-022","WOS95Id":"40824748"},{"Serialnumbers":"411832-023","WOS95Id":"40824748"},{"Serialnumbers":"411832-024","WOS95Id":"40824748"},{"Serialnumbers":"411832-025","WOS95Id":"40824748"},{"Serialnumbers":"411832-026","WOS95Id":"40824748"},{"Serialnumbers":"411832-027","WOS95Id":"40824748"},{"Serialnumbers":"411832-028","WOS95Id":"40824748"},{"Serialnumbers":"411832-029","WOS95Id":"40824748"},{"Serialnumbers":"411832-030","WOS95Id":"40824748"},{"Serialnumbers":"411832-031","WOS95Id":"40824748"},{"Serialnumbers":"411832-032","WOS95Id":"40824748"},{"Serialnumbers":"411832-033","WOS95Id":"40824748"},{"Serialnumbers":"411832-034","WOS95Id":"40824748"},{"Serialnumbers":"411832-035","WOS95Id":"40824748"},{"Serialnumbers":"411832-036","WOS95Id":"40824748"},{"Serialnumbers":"411832-037","WOS95Id":"40824748"},{"Serialnumbers":"411832-038","WOS95Id":"40824748"},{"Serialnumber,"_2":{"dataShape":{"fieldDefinitions":{"WOS95Id":{"name":"WOS95Id","description":"WOS95Id","baseType":"STRING","ordinal":0,"aspects":{}},"OperationName":{"name":"OperationName","description":"OperationName","baseType":"STRING","ordinal":1,"aspects":{}},"OperationDescription":{"name":"OperationDescription","description":"OperationDescription","baseType":"STRING","ordinal":2,"aspects":{}}}},":"411832-039","WOS95Id":"40824748"},{"Serialnumbers":"411832-040","WOS95Id":"40824748"},{"Serialnumbers":"411832-041","WOS95Id":"40824748"},{"Serialnumbers":"411832-042","WOS95Id":"40824748"},{"Serialnumbers":"411832-043","WOS95Id":"40824748"},{"Serialnumbers":"411832-044","WOS95Id":"40824748"},{"Serialnumbers":"411832-045","WOS95Id":"40824748"},{"Serialnumbers":"411832-046","WOS95Id":"40824748"},{"Serialnumbers":"411832-047","WOS95Id":"40824748"},{"Serialnumbers":"411832-048","WOS95Id":"40824748"}]},"_3":{"dataShape":{"fieldDefinitions":{"WOS95Id":{"name":"WOS95Id","description":"WOS95Id","baseType":"STRING","ordinal":0,"aspects":{}},"OperationName":{"name":"OperationName","description":"OperationName","baseType":"STRING","ordinal":1,"aspects":{}},"StepName":{"name":"StepName","description":"StepName","baseType":"STRING","ordinal":2,"aspects":{}},"StepDescription":{"name":"StepDescription","description":"StepDescription","baseType":"STRING","ordinal":3,"aspects":{}}}},"rows":[{"WOS95Id":"","OperationName":"","OperationDescription":""},{"WOS95Id":"40824748","OperationName":"1000","OperationDescription":"1000-ASSIGN SN"},{"WOS95Id":"40824748","OperationName":"1005","OperationDescription":"1005-REC & ID"},{"WOS95Id":"40824748","OperationName":"1010","OperationDescription":"1010-GRIT BLAST"},{"WOS95Id":"40824748","OperationName":"1015","OperationDescription":"1015-INCOMING QC"},{"WOS95Id":"40824748","OperationName":"1999","OperationDescription":"1999-CLOSE GATE 1"}]}}]} 

The servelet returns the data as contentType =  application/json;charset=UTF-8,   when I try to access this url using content loader functions getJson or getText using:

 

var params = {
headers: '{"Accept":"application/json","Content-Type":"application/json","appKey":""}',
ignoreSSLErrors: true, 
url: 'https://localhost:8443/Thingworx/TwxDBServlet?WorkOrder=40824748',
timeout: 60000,
};

var result = Resources["ContentLoaderFunctions"].GetJSON(params);

 

it just returns:   {"headers":{"Accept":"application/json","appKey":"","Content-Type":"application/json"}}

ACCEPTED SOLUTION

Accepted Solutions
kyetzer
12-Amethyst
(To:kyetzer)

I just figured out what the issue was.  I had the return type set to JSON and an error was being thrown because of the character '_' being used in key names

View solution in original post

3 REPLIES 3
kyetzer
12-Amethyst
(To:kyetzer)

I just figured out what the issue was.  I had the return type set to JSON and an error was being thrown because of the character '_' being used in key names

Alessio
15-Moonstone
(To:kyetzer)

Are you saying that ThingWorx does not like a JSON response if it contains an underscore in a key?

That looks odd.

kyetzer
12-Amethyst
(To:Alessio)

yes it is throwing an error

Announcements


Top Tags