APIs & Integrations

herrygupta
Participant

Updating table row with hubdb api is showing xml parsing error

I am using hubdb api to update specific row in the table and it is showing me following error.

XML Parsing Error: no root element found Location: https://api.hubapi.com/hubdb/api/v2/tables/tableid/rows/rowid?portalId=portalid&hapikey=apikey Line Number 1, Column 1:

I passed the portal id specifically because it was giving error of portal id is required. After passing portal id it starts showing xml parsing error.

Please help me with this.

0 Upvotes
9 Replies 9
herrygupta
Participant

Updating table row with hubdb api is showing xml parsing error

Hi Leif,

I tried with the javascript code that you gave. There is small error in your code. quote is missing in the end of line number 10(xhr.open).

After closing the quote it is still not working and when I alert the xhr.status and xhr.readystate it returs xhr.readystate 4 and xhr.ready status 405 and 405 means method not allowed.

405 Method Not Allowed

The HyperText Transfer Protocol (HTTP) 405 Method Not Allowed response status code indicates that the request method is known by the server but is not supported by the target resource.

and then it gave same error in the console. If I change the post method to put according to the hubspot

Screenshot

Captured with Lightshot


then it gave CORS error in console.

Any solutions for this.

0 Upvotes
LeifInouye
HubSpot Alumni
HubSpot Alumni

Updating table row with hubdb api is showing xml parsing error

Hi Herry!

My apologies for the error, I must have accidentally removed that last quote when editing out my hAPIkey.

I've confirmed with colleagues-- that API endpoint definitely doesn't work with ajax/cors requests as it would result in exposing your hapikey. You will need to use some server side scripting if you intend to update HUBDB tables that way.

0 Upvotes
herrygupta
Participant

Updating table row with hubdb api is showing xml parsing error

Hi @Leif

Do you have any news on this for me. Any way to resolve this. Its been almost 20 days and this issue is still there.

Any help on this please.

Thanks!!

0 Upvotes
herrygupta
Participant

Updating table row with hubdb api is showing xml parsing error

Hi Leif,

Cors error is with the put request and while using post request it is returning the same xml parsing error. How can this be sorted? status is returning 405 instead of 200. 405 is showing method not allowed and I am using this method on the hubspot page itself. It is not outside of hubspot that gives cors error. And cors error is also stating that method not found.

Please verify if this issue is from hubspot's end.

Thanks!!

0 Upvotes
herrygupta
Participant

Updating table row with hubdb api is showing xml parsing error

Hi @Leif,

Any update on this. This issue is still there.

0 Upvotes
LeifInouye
HubSpot Alumni
HubSpot Alumni

Updating table row with hubdb api is showing xml parsing error

Hi Herry,

I was able to successfully send a POST request to a HubDB table in my portal within the console. This is the script I wrote:

   var xhr = new XMLHttpRequest();
    var object = {
     "values": {
        "1": "test",
        "2": "test",
        "3": "test@hubspot.com"
      }
    };

    xhr.open('post','https://api.hubapi.com/hubdb/api/v2/tables/XXXXXX/rows?hapikey=XXXXXXX);

        xhr.onreadystatechange = function() {
            if(xhr.readyState == 4 && xhr.status == 200) {
                alert(xhr.responseText);
            }
        }

    xhr.setRequestHeader('Content-type', 'application/json');
    xhr.send(JSON.stringify(object));

I am not familiar with the jquery methods for using AJAX but in general I would try to defer to vanilla Javascript when possible. My assumption is that the object you were passing to the table wasn't being processed properly. Give the above a try.

0 Upvotes
herrygupta
Participant

Updating table row with hubdb api is showing xml parsing error

Hi Leif,

Any news on this.

0 Upvotes
herrygupta
Participant

Updating table row with hubdb api is showing xml parsing error

Hi Leif

Here is the code that I am using.

var jsonnew ={
"values": {
"1": "updated"
}
} ;

$.ajax({
type: 'POST' ,
url: 'https://api.hubapi.com/hubdb/api/v2/tables/tableif/rows/rowid?portalId=portalid&hapikey=apik',
data: JSON.stringify(jsonnew),
dataType: "JSON",
contentType: "application/json",
success: function(data){
console.log(data);
},
failure: function(errMsg) {
console.log(errMsg);
console.log(data);
}
});

and I am using it inside the same portal on hubspot page. I have tried with both PUT and POST request.

0 Upvotes
LeifInouye
HubSpot Alumni
HubSpot Alumni

Updating table row with hubdb api is showing xml parsing error

Hi Herry,

Would you mind sending me your code? I specifically would like to see how you're formatting your payload.

Thanks!

0 Upvotes