Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
11 replies
Subscribers
7 subscribers
Views
3849 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
I am trying to display Twitter feeds as a list of titles/hyperlinks. Previously,
wendys593
over 11 years ago
I am trying to display Twitter feeds as a list of titles/hyperlinks. Previously, this was done very easily by using a Twitter RSS feed, but that is no longer supported. I am able to use the Twitter API to get the feeds in JSON format, but am having difficulty parsing it using readjson, readjsonarray functions. Does anyone have any experience in doing this, or could help me with an expression to parse the data? I have also tried using the function jsontoxml to convert to xml and use xpath, but that also does not return results. Thanks in advance....
OriginalPostID-73475
OriginalPostID-73475
Discussion posts and replies are publicly visible
0
malcolm.ross
Appian Employee
over 11 years ago
Hi Wendy.. I have done this.. Use the OAuth Smart Services to call the Twitter REST API.. then use the JSON to XML function and parse the response as XML instead of JSON.. Here is an example you might use to extract all the posts from an array of twitter posts
xpathsnippet(jsontoxml(ac!ResponseBody), "/json/e/text/text()")
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
wendys593
over 11 years ago
Thanks Malcolm! I was able to get this working exactly as you said, now the only issue is that I am getting an error with the xpath expression if I try to pull back too much data. Everything works fine for approx 10 tweets, but more than that causes an error. (xpathsnippet(jsontoxml(pv!ResponseBody), "/json/e/text/text()") (Expression evaluation error at function 'xpathsnippet': Error evaluating function 'xpathsnippet' : An error occurred while trying to parse the XML stream.) ) Have you ever seen this before? Thanks for your help!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
malcolm.ross
Appian Employee
over 11 years ago
My system does not experience that issue.. What version of Appian are you using? You might be hitting some data cap thresholds that were present in earlier versions.. Or you might need to adjust data caps in your custom.properties file.. You can also toggle the amount of twitter posts you receive at once via the Twitter API so that you don't retrieve large data sets.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Kesava Kuchipudi
over 11 years ago
Malcolm,
Looks like the execution is failing at xpathsnippet function call. I could see the json data parsed successfully in XML format and the xpathsnippet function is failing when we search for text or id list. Strangely jboss is also not throwing any error. if data cap is an issue the xml conversion function shouldn't work? any ways I could confirm that no truncation has happened after parsing the json to xml. Most likely data cap property applies only for user entered text I believe not when the system activity nodes updating them. Perhaps there are some limitations on xpathsnippet function. Do you know if there are any known limitations?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
malcolm.ross
Appian Employee
over 11 years ago
I have not seen any issue or aware of any issue with data caps and xpathsnippet.. I would suggest performing the jsontoxml function and validating the result in an XML validator to ensure it is not malformed.. also, be sure to note your version of Appian you are using.
www.w3schools.com/.../xml_validator.asp
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Kesava Kuchipudi
over 11 years ago
Thanks Malcolm. I have validated the response xml and it says no error found. We are using appian 6.7.1. My JSON data is having 59000 characters and xml representation is around 66850 in length.my actual data cap setting is at 10000 which means it did not failed to convert json to xml though the data is well above the limits. We tried everything possible and most likely will end up writing a custom function to extract the data from JSON representation directly to an array. I could see a plugin already in shared components and some reason it is not working as expected with json array representation.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
malcolm.ross
Appian Employee
over 11 years ago
I just tested on my Appian Cloud 7.2 environment.. Retrieved the last 100 tweets from the Appian twitter account.. JSON response was 138709 characters.. XML conversion was 179401 characters.. everything worked perfectly.. parsed out the XML using xpathsnippet to retrieve the 100 tweets and twitter IDs into two text arrays using these functions - xpathsnippet(jsontoxml(ac!ResponseBody), "/json/e/text/text()") and xpathsnippet(jsontoxml(ac!ResponseBody), "/json/e/id/text()")
If you continue to experience this issue, I would suggest opening up a support ticket to help resolve. The primary difference between our environments is the version of Appian.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
malcolm.ross
Appian Employee
over 11 years ago
For your custom function idea.. I would suggest just downloading and enhancing the source code of the existing JSON functions.. These were developed and shared by an Appian partner.. my suspicion of why those JSON parsing functions are not working is that they might not be able the handle nested array structures inside a JSON string.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Kesava Kuchipudi
over 11 years ago
Thanks Malcolm for your inputs. We are experiencing this issues and I will ask our admin to raise a support ticket. and Yes, I am downloading the plugin and enhancing the source code (adding a new function thought) to handle the json array representation. Fortunately the developer has included source code in the jar file. I will let you know how it goes
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Kesava Kuchipudi
over 11 years ago
the custom function to read the json response which is in the array form did worked for us. At this point this function is not in the good shape which can be shared with broader community as we have to implement something quick and dirty for some urgent needs. Thanks for your prompt response
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>