APIs & Integrations

JSrivastava
Member

Encountered NO CORS policy error while updating ticket status

I have a hubspot website page on which i am showing the ticket detail. Now i need to update ticket details from that page and it should we updated on ticket record also. And I am getting NO CORS policy error when i hit the api to update ticket detail.

 

ERRROR - 

Access to fetch at 'https://api.hubapi.com/crm/v4/objects/tickets' from origin 'https://22802714.hubspotpreview-na1.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

 

Thanks,

0 Upvotes
7 Replies 7
JSrivastava
Member

Encountered NO CORS policy error while updating ticket status

Hi @Syeda_Fatima do we have any kind of standard function to update and insert record of ticke modules.
Thsnkd

0 Upvotes
Syeda_Fatima
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Encountered NO CORS policy error while updating ticket status

Hey @JSrivastavaUnfortunately, you cannot use the Design Tool to hit the API to update or insert records in the ticket module.

 

You will need to use a custom code solution to achieve this. You may also need to update your CORS policy to allow the API requests to be sent to your server.

0 Upvotes
JSrivastava
Member

Encountered NO CORS policy error while updating ticket status

Hi @Syeda_Fatima 

We got your point can you please assist us how and where we can implement our custom code to hit an API on a button click which is on my HubSpot website page.
Do you have any kind of reference link by which we can achieve this.

Thanks.

0 Upvotes
JSrivastava
Member

Encountered NO CORS policy error while updating ticket status

Hi @Syeda_Fatima we have tried your solution but we are getting same error. I have a query can we hit api in design tool (page module).
Thanks

0 Upvotes
Syeda_Fatima
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Encountered NO CORS policy error while updating ticket status

No @JSrivastava, it is not possible to hit an API in the page module of a design tool. The page module is used to create the structure of a page and to add content elements, such as text, images, videos, and forms. It does not have the capability to interact with an API.

0 Upvotes
Syeda_Fatima
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Encountered NO CORS policy error while updating ticket status

Dear @JSrivastava , Perhaps you missed anything while trying to follow the suggestion. Please do double check.

 

And No, you cannot hit an API in the Design Tool (Page Module). You can, however, use the API to retrieve data or get information and then use that data or information to populate the page with content.

0 Upvotes
Syeda_Fatima
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Encountered NO CORS policy error while updating ticket status

Hey @JSrivastava, To resolve this issue, you will need to set the Access-Control-Allow-Origin header in your response.

 

This can be done by adding the following code to your application:

Access-Control-Allow-Origin: *

 

You can also specify specific domains instead of using the wildcard if you wish. Once the header is set, the browser will allow the request.

0 Upvotes