Jump to content

Get JSON result from X-Callback-Url success


Zenflow

Recommended Posts

Im trying to make a search workflow for the Bear notes app, the success url is called but no JSON data seems to be included. Does anyone know why this wouldn't work?



I have a bash script that is called when the keyword is typed, hardcoded to search for "test":

open -g "bear://x-callback-url/search?term=test&show_window=no&token=MY_TOKEN&x-success=alfred://runtrigger/com.myapp.bear/displayresults/"



Then an external trigger that executes this bash script:

query=$1
# Check if query is empty
if [ -z "$query" ]; then
    echo "No query was provided" >&2
else
    echo "The query is: $query" >&2
fi

 

image.png.c0eab5011e83d922fa5ae826eb08626f.png
Link to comment

Welcome @Zenflow,

 

I don’t use Bear, but different parameter names can’t be the problem, you can’t mix and match arguments from one tool to another. The likely issue is that you’re not URL-econding the x-success part, thus bear is interpreting it as its own when it has to interpret it as something to call later.

Link to comment
1 hour ago, vitor said:

Welcome @Zenflow,

 

I don’t use Bear, but different parameter names can’t be the problem, you can’t mix and match arguments from one tool to another. The likely issue is that you’re not URL-econding the x-success part, thus bear is interpreting it as its own when it has to interpret it as something to call later.

Just to be clear the x success url is being called from bear with the data string in a parameter called notes and succesfully triggers the external trigger but it seems to only look for data in the argument called argument.

If I call alfred://runtrigger/com.myapp.bear/displayresults/?argument=test it forwards "test" but if I call alfred://runtrigger/com.myapp.bear/displayresults/?notes=test it forwards an empty string "".
 
Can I get around this?

Link to comment
7 minutes ago, Zenflow said:

x success url is being called from bear with the data string in a parameter called notes

 

Please provide a real example. What you want to do is almost certainly possible but to be able to help you we need to properly understand what you’re doing.

 

Like I said, you can’t mix and match parameters from different apps. There’s no reason for Alfred to understand ?notes, like there is no reason for Bear to understand ?argument. Or both apps could understand those but they would do so for their own purposes.

Link to comment
17 minutes ago, vitor said:

 

Please provide a real example. What you want to do is almost certainly possible but to be able to help you we need to properly understand what you’re doing.

 

Like I said, you can’t mix and match parameters from different apps. There’s no reason for Alfred to understand ?notes, like there is no reason for Bear to understand ?argument. Or both apps could understand those but they would do so for their own purposes.

Sure, I want to be able to search for Bear notes within alfred and display the results as I type.

So the easiest way to interface with Bear seems to be though it's X-Callback-URLs 
https://bear.app/faq/x-callback-url-scheme-documentation/

There I found the search url which returns the found notes through the success callback.
https://bear.app/faq/x-callback-url-scheme-documentation/#search

So then I thought I could pass a URL to an external trigger as success URL since that seem to be the only way to interface with Alfred through a URL.

Link to comment
8 minutes ago, Zenflow said:

and display the results as I type.

 

Then you can’t do it with that approach, because you’re triggering Alfred and running a Script, not presenting any result. You’d need a Script Filter. X-Callback-URLs are the wrong tool for the job, they are meant to run something once.

 

You should probably take a look at the existing Alfred workflows for Bear, you can find a handful of them on GitHub. For example:

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...