So I have done something similar before, and it worked just fine, but for some reason when I try to update a row in a HubDB table I am getting the error "Method PUT is not allowed by Access-Control-Allow-Methods in preflight response." Did something change to not allow this, or am I just missing something? Ill post my code below.
That's a good question. Depending on your use case, you might be able to accomplish what you're looking to do with an IPaaS solution like Zapier. If you need a simple hosting solution for your server side scripts, you might consider solutions like Heroku or AWS:
I need to update the Hubdb cell data and create a new deal based on user's input, I am trying to do so from the client-side but I get the same error.
As per the discussion, I come to know I have to request it from server-side.
I don't have running web-server and actually I'm not that much profecient in server setup, can you please educate me which would be the best option for me to achieve this.
Is there any library or integration available which gets data by API (call PUT or POST request from client-side) and make request on backend-side and do the task.
Only GET methods should allow CORS; other methods should not allow CORS, so I'm not entirely sure why it's possible to create a new row using client-side JavaScript.
I'll touch base with product on this; since the HubDB API should not allow CORS on any methods other than GET, the fact that it's possible to create a row is a bug. I wouldn't recommend depending on this functionality, since it's not officially supported and is likely to be fixed in the near future.
Going forward, you'll need to make POST/PUT requests to the HubDB API server-side, with the necessary authentication. See this developer doc:
What issue are you facing? This post was originally addressing the 'Method PUT is not allowed'; the resolution there is that the HubDB API doesn't support client side requests for write methods (POST, PUT, etc.). It is not possible to make client side write requests to the HubDB API. You'll have to make the requests server side.
Does that address your question? If not, could you give me some more details on what exactly you're trying to do / what issue you're facing?
I'm able to create a new row using ajax post request but when I update the same row using ajax put request it gets fail, here is the exact message shows in the console log
Method PUT is not allowed by Access-Control-Allow-Methods in preflight response.
HubDB endpoints that support GET support CORS, but this only applies to GET methods. Other methods (and the GET all tables endpoint) require authentication, and will not support CORS. For those methods, you'll need to make the requests server-side with authentication, either an API key or access token.
It really depends on what exactly you're looking to build, and how what you have is currently structured. If you have an existing web server that you can add a (relatively) simple script to, you could make requests to that server and then hit the HubSpot API from that server. If you don't have access to an existing web server, you might consider a lightweight solution like Heroku or AWS to host a simple web server to handle the proxying.
Happy to give more specific feedback if you want to share more details regarding your goal and existing process.
I understand; that makes much more sense. HubDB endpoints that support GET support CORS, but this only applies to GET methods. Other methods and the GET all tables API require authentication, and will not support CORS. For those methods, you'll need to make the requests server-side with authentication, either an API key or access token.
That's exceedingly strange. Are you making these requests from the browser? The HubDB endpoints only support CORS for GET requests, so you'd be seeing an error like this if you were trying to make PUT requests client-side. Do you have any other details about your setup that might be useful? Are you using a particular language, request library, or hosting service that might be related?
Ya, I am trying to update it from the browser. It is an interface for people in my company to search sort create and update content in the database. It uses jquery/javascript.
I just gave it a shot on my end, and I was able to update that row with some test value successfully. I think there might be something malformed in your request URL and/or your request body. The request URL and body should look like the following:
I tried making The body exactly the same, but still got the error "Method PUT is not allowed by Access-Control-Allow-Methods in preflight response." I though maybe there was something wrong with my api key so a double checked and that doesn't seem to be it ( also I have another method for the same table that creates rows using the same api key and that works fine ).
Hmm... That looks like an error response from us, but it also looks different than the "Method not allowed" you mentioned earlier. I was looking for the request body right before sending the request. The code you included has variable names (e.g. custom_name, custom_overview, etc.) so it's tough to know if those might be malformed or something.
I did try to instead send just a default value instead of a variable, with the same results. It was just a simple "Test" text. Also I checked the thing I had made before, which did previously work, now gets the same error.