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

ThingWorx Navigate is now Windchill Navigate Learn More

Translate the entire conversation x

post request for service doesnt work

IA_10816220
12-Amethyst

post request for service doesnt work

hello,

 

i am trying to work with the thingworx api , i can do GET request to get properties values and it is fine but when i tried to test the POST request to run a service, it doesn't work , although the service itself works fine it has no inputs and it output the data in infotable (it has QueryPropertyHistory service in it, that returns the infotable)

and i am testing the api locally with this links (i double checked the names)
http://localhost/Thingworx/Things/Eastern.Security.Vehicle.5971/Services/TestQueryData

i am also using API key in postman header and it works fine when i do get property,

her is the error i get in the post man 

 

<!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>

 


also i tried to check the monitor window in the composer under script log i cant see any errors or indications that the script or the service has been executed

thank you,

ACCEPTED SOLUTION

Accepted Solutions

- when GET is working I assume authorization is fine (via appkey or basicauth)

- for POST you need to specify Header "Content-Type: application/json" and best also header "Accept: application/json". Also you need to pass required parameters of the service in the body.

When you get the 500 error you might also want to check the TWX Logs (Application/Script/..) if you find what caused the error. Maybe your service is being executed as you want but has an issue while executing (e.g. parameter is missing).

View solution in original post

4 REPLIES 4

More about this error: 

Hi @IA_10816220 ,

 

Can you show us the headers you setup in Postman for this Service request? (make sure to remove any sensitive information in there, of course)

- when GET is working I assume authorization is fine (via appkey or basicauth)

- for POST you need to specify Header "Content-Type: application/json" and best also header "Accept: application/json". Also you need to pass required parameters of the service in the body.

When you get the 500 error you might also want to check the TWX Logs (Application/Script/..) if you find what caused the error. Maybe your service is being executed as you want but has an issue while executing (e.g. parameter is missing).

Hi @IA_10816220 ,


I wanted to follow up with you on your post to see if your question has been answered. 


If so, please mark the appropriate reply as the Accepted Solution for the benefit of other members who may have the same question.


Of course, if you have more to share on your issue, please let the Community know so that we can continue to support.


Thanks,
Abhi

 

Announcements


Top Tags