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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Thing Service returns "500 Unexpected Error - Contact your system administrator for more"

DigitalFactory
4-Participant

Thing Service returns "500 Unexpected Error - Contact your system administrator for more"

Hi, 

we would like to call a Service, which returns a JSON, when you call it with a POST request. 

Unfortunately, we get the following response when we call the Service via Postman:

The URI we use: http://localhost:8080/Thingworx/Things/{ThingName}/Services/Get_All_Sensor_Data

The Response: 

<!DOCTYPE html>
<html>

<head>
  <title>Unexpected Error</title>
  <script>
    function clickAndDisable(link) {
              link.onclick = function(event) {
                event.preventDefault();
              }
            }
  </script>
</head>

<body>
  <div class="widget-panel widget-container widget-content" style="overflow: auto;">
    <div class="widget-content widget-image undefined" id="error_Image-1">
      <img src="/Thingworx/images/ThingworxLogo.png" alt="Errors"/>
      </div>
    </div>
    <div id="error_Panel-1">
      <p>500 Unexpected Error - Contact your system administrator for more details</p>
      <a href="/Thingworx" onclick='clickAndDisable(this);'>Back to Composer</a>
    </div>
</body>

</html>

Our current code:  (not final)
var result = {};
if(code >= 500)
{
try
{
result.message = Resources["JSONErrorResource"].GetBadRequest(
{content: {"plop": "error"}});
result.status = "200";
}
catch( err )
{
logger.error( "The following error occured. " + err );
result.status = "500";
result.message = "Some Error message here";
}
}
else
{
result.status = "200";
result.message = "ok";
}
4 REPLIES 4

HI @DigitalFactory.

 

There are a lot of questions here:

 

  • What happens when you run the service directly in Composer?
  • What account (appKey) does the service run under when calling the Post request?
  • Can you provide a screenshot of your Post request in Postman with the headers so we have a better idea of what you're sending?

Regards.

 

--Sharon

HI @slangley

thanks a lot for your answer. 
Please find the requested information below: 

When we execute the code in composer we get the following error message: 
"Error executing service Get_All_Sensor_Data. Message :: ReferenceError: "code" is not defined. - See Script Error Log for more details."

The appKey is bount to the Administrator. I know that is not best practice and just used for test purposes.

Please find a screenshot of our post man request attached.

slangley
23-Emerald II
(To:slangley)

Hi @DigitalFactory.

 

Since executing the service in Composer directly is failing, there is clearly a problem with the service itself.  Therefore, it's not going to work in Postman.

 

Have you tried troubleshooting the code for this service to determine the cause of the problem?  This article may provide some guidance there.  If you run across any issues while troubleshooting, please feel free to reach out.

 

Regards.

 

--Sharon

slangley
23-Emerald II
(To:slangley)

Hi @DigitalFactory.

 

Have you made any progress on resolving your issue?  If so, please share the details here for the benefit of others on the community.

 

Regards.

 

--Sharon

Top Tags