Invalid XML in blog importer and Blog API Issues with cURL [solved]



I am trying to use the get blog posts API and the limit variable is not working. For example, this GET will only return 20 and fires back a "Limit" is not recognized as an internal or external command, operable program or batch file statement.

curl -v -X GET

Also, with the JSON that is returned, I have tried to convert over to XML using as well as coolutils converter (which i did in the past) and I am getting an invalid XML error when trying to import. Any help would be appreciated on this. I am simply trying to clone one of our sites.

Thank you.


Hi @ajlaporte

It will depend on the OS and terminal you’re using, but the & and ? characters are generally reserved as operators in most shells. You’ll need to escape those characters in the command using backslashes \.

curl -v -X GET

I’m not seeing any issues myself when using blog data with, but it’s possible that the JSON you’re getting from the curl commend may be truncated or formatted incorrectly because of the errors returned by your original command.


So I got to work by wrapping the url in quotes (on windows in cmd). I am still having issue when importing the xml file though. I only have 2 posts in the xml and I am still getting an invalid error when importing.

any thoughts?


I’ve tried multiple times now to use this formatter and to convert JSON over to XML. Every time, I get the same invalid error. Is there any way to export the HubSpot content as an XML so you can simply reimport it into another portal? I know this has been requested in the feature request/ideas forums.


Hi David,

Do you have any suggestions on why this isn’t working when I try to import it? I have reached out to support and they said “I see that David Adams has responded to you in the Developer’s Forum” and if I had more questions to respond to them, which I did, and I am not getting a response. This is really frustrating me as all the XML checkers I am running are telling me the XML is valid.



Are you getting an error converting the JSON to XML? Or importing the converted XML into a separate system? What specific error are you seeing? Our APIs produce valid JSON, so if you’re having trouble converting or importing that data it might be worth reaching out to the creators of those separate tools.

You would be able to get XML for the content of a blog by looking at the RSS feed of the blog, but it won’t contain the same metadata you’d get with the Blog API.


I am getting an invalid XML Error when importing to the blog importer inside of HubSpot.

For testing, I grabbed a post via the API from a test portal (the sample post that you get when you spin up a new portal) and then converted that JSON data to XML and imported it back into the same portal and still got an invalid XML Error:

The file for this import is invalidly formatted: Invalid XML content ;

I also tried grabbing the XML from the rss.xml feed and importing that but still no go. The error I got for that was:

The file for this import is invalidly formatted: Invalid XML content at location [Line: 14, Column 1]; channel -> item -> null -> description

I was working with another dev in the HubSpot Developer Slack and he too had issues importing into his own portal using the blog importer.



David, have you been able to look into this further?


The Blog Importer tool is designed to work with a few specific blog tools (currently Wordpress and Squarespace) that have XML exporting tools. It’s not designed to work with a standard RSS feed (which HubSpot generates), and while it would be possible to convert the JSON from the Blog API to XML, it’s not going to be the same format the the import tool is designed to work with.

If you’re already using the blog API to pull the posts, you’re best option would be to also use the Blog API to recreate those posts in the other HubSpot portal.


Do you have an example of how to go about doing this that you could point me towards?


Hi David,

Is there a way to only request certain fields back from the Blog Listing API? For example, can I add a parameter to grab only the name and post_body variables from the JSON Data or am I going to have to filter out the items on my end once I get the data from the full get ?

I only ask because the API needed to create posts only allows 18 fields in the post JSON whereas the get returns way more than that. I was looking to only get the 18 fields that are needed to create them.



@ajlaporte we don’t have a way to specify which fields are returned, so you’ll always get the entire object, and you’d need to filter that data before making the POST request to create the new blog post.


@dadams Sounds good. Thank you for your assistance on this.



@dadams One more thing i noticed, when creating a blog post via API, there is an issue with items that have single quotes in the name field. They wont import correctly. For example, I had issues creating a blog via API when the name value was:

“name” : “We’re doing something, so we’ve done blah blah blah”

I had to remove the ' in order to make the import successful. I tried escaping it by using \' but it still didnt work. Any thoughts on this?



Are you getting an error for those items? Or is there a formatting problem with the posts when they’re created?

If you’re getting an error, are you logging the body of the response? It should have more details about the problem.


I Get

curl: (6) Couldnt resolve host 'doing’
curl: (6) Couldnt resolve host 'something’
curl: (6) Couldnt resolve host ‘so’

the full statement (with key removed) is as follows:

curl -X POST -H “Content-Type: application/json” -d ‘{“content_group_id”: 444444444, “name”: “We’re doing something, so we’ve done blah blah blah”, “post_body”: “test”}’ “

I’m doing this statement in terminal on a linux box.



This is another character escape issue, but from my experience the single quotes don’t escape correctly, so you’ll probably have more luck wrapping the data in double quotes and escaping those:

curl -X POST -H “Content-Type: application/json” -d “{“content_group_id”: 444444444, “name”: “We’re doing something, so we’ve done blah blah blah”, “post_body”: “test”}” “


That did the trick. Thank you David. I’m going to edit the title of this to be more accurate in case those with similar issues are looking on the forums.


curl -X POST -H “Content-Type: application/json” -d “{“content_group_id”: 444444444, “name”: “We’re doing something, so we’ve done blah blah blah”, “post_body”: “test”}” “ gmail login

that did the tricks. Thanks