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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

CORS error while connecting Thingworx REST API to HTTP request- JavaScript XHR Vue.JS

shubhamm
10-Marble

CORS error while connecting Thingworx REST API to HTTP request- JavaScript XHR Vue.JS

I have already configure my Tomcat serve for CORS still i am not able to access my api and i am getting " Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource."  

When i am trying to access the API using Postman i am getting 403 error.

For reference please check attached images. 

 

ACCEPTED SOLUTION

Accepted Solutions

hii Sharon,

 we have followed  https://www.ptc.com/en/support/article/CS229450  article that resolved our issue. 

Thanks and Regards,

Shubham 

View solution in original post

10 REPLIES 10
slangley
23-Emerald II
(To:shubhamm)

Hi @shubhamm.

 

Have you made any changes to filter for CORS based on any documentation PTC provides?  If so, please provide specifics on the changes that were made.

 

What versions of Tomcat/ThingWorx are you running?

 

Here is an article that may help depending on the ThingWorx version you're running.

 

Regards.

 

--Sharon

Tomcat 8.5.32

Thinworx 8.3

slangley
23-Emerald II
(To:slangley)

Hi @shubhamm.

 

Have you made any changes to filter for CORS based on any documentation PTC provides?  If so, please provide specifics on the changes.

 

Was the article I provided helpful?

 

Regards.

 

--Sharon

<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
    <param-name>cors.allowed.origins</param-name>
    <param-value>*</param-value> 
</init-param>
<init-param>
    <param-name>cors.allowed.methods</param-name>
    <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
</init-param>
<init-param>
    <param-name>cors.allowed.headers</param-name>
    <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,Access-Control-Allow-Origin,Access-Control-Allow-Host</param-value>
</init-param>
<init-param>
    <param-name>cors.exposed.headers</param-name>
    <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials,Access-Control-Allow-Host</param-value>
</init-param>
<init-param>
    <param-name>cors.support.credentials</param-name>
    <param-value>false</param-value>
</init-param>
<init-param>
    <param-name>cors.preflight.maxage</param-name>
    <param-value>10</param-value>
</init-param>
</filter>
<filter-mapping>
  <filter-name>CorsFilter</filter-name>
  <url-pattern>*</url-pattern>
</filter-mapping>​

This is my tomcat configuration and now i am able to access Thingworx API using Postman But again i am getting same error in my browser. 

slangley
23-Emerald II
(To:slangley)

Hi @shubhamm.

 

If one of the previous responses have helped with a solution, please mark the appropriate one as the Accepted Solution for the benefit of others with the same questions.

 

Regards.

 

--Sharon

Hi 

  I try all the solution but still it is not working.
  i am getting same error.

slangley
23-Emerald II
(To:slangley)

Hi @shubhamm.

 

How are you passing the AppKey?  Are you seeing the same error when you try to access it via your browser?

 

This article may help.

 

Regards.

 

--Sharon

slangley
23-Emerald II
(To:slangley)

Hi @shubhamm.

 

Just wondering if the article in the previous post helped to resolve your issue.  If not, please provide the logs located at \ThingworxStorage\logs.  Make sure the logs cover the time period of your testing.

 

Regards.

 

--Sharon

hii Sharon,

 we have followed  https://www.ptc.com/en/support/article/CS229450  article that resolved our issue. 

Thanks and Regards,

Shubham 

Announcements


Top Tags