Invalid XML in blog importer and Blog API Issues with cURL [solved]
Hello,
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 https://api.hubapi.com/content/api/v2/blog-posts?hapikey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&limit=50
Also, with the JSON that is returned, I have tried to convert over to XML using http://jsonformatter.org/ 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.
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 \.
I’m not seeing any issues myself when using blog data with http://jsonformatter.org/, 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.
Invalid XML in blog importer and Blog API Issues with cURL [solved]
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.
Invalid XML in blog importer and Blog API Issues with cURL [solved]
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.
Invalid XML in blog importer and Blog API Issues with cURL [solved]
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.
Invalid XML in blog importer and Blog API Issues with cURL [solved]
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.
Invalid XML in blog importer and Blog API Issues with cURL [solved]
@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.
Invalid XML in blog importer and Blog API Issues with cURL [solved]
@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:
Invalid XML in blog importer and Blog API Issues with cURL [solved]
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:
Invalid XML in blog importer and Blog API Issues with cURL [solved]
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.
Invalid XML in blog importer and Blog API Issues with cURL [solved]
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.
Invalid XML in blog importer and Blog API Issues with cURL [solved]
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.
Invalid XML in blog importer and Blog API Issues with cURL [solved]
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.