JordanX Posted October 23, 2016 Share Posted October 23, 2016 (edited) Working on Workflow...Script Filter Alfredv3.1.1 (737) Mac O SX 10.12 Dropbox Link <removed> Trying to get the results displayed as choices in Alfred. Error [ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON With (bash) base_uri="https://xyz.execute-api.us-west-2.amazonaws.com/prod/listfromalfred?user=${user}&task=${data}" post_result=$(/usr/local/bin/curl -X GET ${base_uri}) post_success=`echo ${post_result} | grep items` echo ${post_success} | sed 's/\\//g' This test code works #test='<items><item uid= "test " arg= "one "><title>em11@mail.com</title><subtitle>em11@mail.com</subtitle><icon>icon.png</icon></item></items>' #echo ${test} However, when I call the API I get: 'Response code: 200\n' [2016-10-23 12:19:23][ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON: "<items><item uid= "test" arg= "one"><title>em11@mail.com</title><subtitle>em11@mail.com</subtitle><icon>icon.png</icon></item></items>" Debugging for hours and can't seem to fix the issue. Trying to get the results displayed as choices in Alfred. HELP Edited October 23, 2016 by JordanX Added Dropbox Link Link to comment
deanishe Posted October 23, 2016 Share Posted October 23, 2016 First of all, when you're having a problem, please post the broken workflow somewhere instead of pasting bits of it into the forum. Unless you're doing something very obviously wrong, it's almost impossible to diagnose an issue without being able to run the workflow. And expecting people to rebuild the workflow for themselves to help you debug is unreasonable. That said, the "obvious" error here is that your XML is invalid. There's no closing </items> element in the XML from your API. Presumably, Alfred can't parse the XML because it's invalid, so it's trying to parse it as JSON instead. Link to comment
JordanX Posted October 23, 2016 Author Share Posted October 23, 2016 @deanishe Yes, caught that and updated post. Still getting the same error. Happy to post the Workflow, any suggestions on how/where I should post it? [2016-10-23 12:19:23][ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON: "<items><item uid= "test" arg= "one"><title>em11@mail.com</title><subtitle>em11@mail.com</subtitle><icon>icon.png</icon></item></items>" Link to comment
deanishe Posted October 23, 2016 Share Posted October 23, 2016 Dropbox? Google Drive? Some web server? Link to comment
JordanX Posted October 23, 2016 Author Share Posted October 23, 2016 Dropbox link added Link to comment
deanishe Posted October 23, 2016 Share Posted October 23, 2016 You're not cleaning the server response properly. The server sends back this: "<items><item uid= \"test\" arg= \"one\"><title>em11@mail.com</title><subtitle>em11@mail.com</subtitle><icon>icon.png</icon></item></items>" But you only remove the backslashes: "<items><item uid= "test" arg= "one"><title>em11@mail.com</title><subtitle>em11@mail.com</subtitle><icon>icon.png</icon></item></items>" You still need to strip the surrounding double quotes and remove the spaces after uid= and arg=: <items><item uid="test" arg="one"><title>em11@mail.com</title><subtitle>em11@mail.com</subtitle><icon>icon.png</icon></item></items> Link to comment
deanishe Posted October 24, 2016 Share Posted October 24, 2016 (edited) Out of interest, what shell voodoo did you use to do that? Or did you fix the server response (which seems to be incorrect)? Edited October 24, 2016 by deanishe Link to comment
JordanX Posted October 27, 2016 Author Share Posted October 27, 2016 Hi, I fixed it on the server side by cleaning up the XML (backslashes and d.quotes) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now