Recent searches


No recent searches

Working with JSON



Posted Mar 26, 2021

This is a continuing discussion about the article Working with JSON in the developer documentation.


0

10

10 comments

To convert JSON into readable date to be used in Excel I suggest downloading and install Microsoft Power Query Add-in, It's a really powerful tool that can read and convert JSON data straight into Excel.


Download link: https://www.microsoft.com/en-gb/download/details.aspx?id=39379 

0


Hi Stassa. This article was more of an example on working with JSON rather than a solution to fully export and import production article data.

You would have to modify the code to pull down images using the Articles Attachment APIs, save those images somewhere, then use the Create Article Attachment API.

This "Backing up your knowledge base with the Zendesk API" is also an article and example (i.e. for demonstration purposes) of pulling article data. It might have some additional useful info.

This comment on the above article, in particular, speaks to an idea on handling attachments:
https://develop.zendesk.com/hc/en-us/articles/360001074288-Backing-up-your-knowledge-base-with-the-Zendesk-API?page=2#comment_360000439047

Hope there are some ideas here that help get you to your next step.

0


Any suggestions for importing the JSON.  I was able to create the JSON to get the data (articles from sandbox), but it didn't pull any of the pictures. How do I get the pictures using curl to create the JSON.

I am am unable to load the JSON I created. (I do know the correct domain and credentials in the command)

curl https://mydomain.zendesk.com/api/v2/help_center/sections/360022690834/articles.json ^
-d '{"article": {"title": "Taking photos in low light", "body": "Use a tripod", "locale": "en-us" }, "notify_subscribers": false}' ^
-v -u stassa@mydomain.com:mypassword -X POST -H "Content-Type: application/json"

0


We are trying to use API to bring in tickets from a partner system.  The lack of line breaks makes the ticket description almost unusable.  Is there a way to make the JSON pretty in Zendesk?

 

EDIT: I found that we can use "html_body" in place of "body" to send formatted comment text through the API

1


Yes, that's the best course. Thanks for posting that follow-up Allison.

0


I can send a perfectly formatted JSON from a python script, receive an HTML 201 response status but the JSON data is not processed.  When I change the JSON by force to use double-quotes rather than single-quotes and issue the same API call, I get the desired result.  

There seems to be an absolute insistence by the API to use double-quotes in JSON rather than the default single-quotes.  Can you confirm this?  Thanks in advance.

0


image avatar

Charles Nadeau

Zendesk Documentation Team

Hi Jonah,

Double quotes are required in JSON for strings. From json.org: "A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. "

Charles

0


Thank you, Charles.

Thank you for your prompt reply.  I had a fun time taking an existing Python dictionary (which defaults to single-quotes in Python) and manipulating it sufficiently so that ZD API would ingest it successfully and not treat it as a null payload.

Best, Regards
Jonah

0


image avatar

Charles Nadeau

Zendesk Documentation Team

Hi Jonah,

The easiest way is to use the Python JSON library to convert Python dictionaries to JSON objects before sending them off in your API requests. See https://docs.python.org/3.7/library/json.html. Example:

import json
my_json = json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
# my_json is ["foo", {"bar": ["baz", null, 1.0, 2]}]

0


Allison Ramsey-Henry Thank you so much for the tip about "html body" I was pulling my hair out trying to get the formatting to work with with the api. 

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post