I just discovered that in order to have an API workflow return a value, you have to actually expose it as a public API and call it via API Connector. That’s bonkers to start, and I also have some questions about doing this that aren’t answered in the documentation or anywhere I can find:
1:
How do I authenticate when making a call to my app API? The example I found in this thread was helpful but he just runs it without authentication, which I’d rather not do.
2:
How do I initialize so that the API Connector correctly detects the returned data? I’m trying to return a list of companies, so just for initialization I have the API workflow returning a generic list:
![image](https://us1.discourse-cdn.com/bubble/original/3X/a/7/a7b38f1f81738b4b5da76ca83eefacc031db002f.png)
But when I initialize, in the API Connector, this is what it gives me:
Why am I not getting the correct fields back?
Here’s my API Connector setup if it helps:
Any ideas are welcome, thanks!
For authentication go to your app settings, API tab, and generate a new key. Then in your API connector change authorization to “Private key in header” and the key is “Bearer [your key]”
Now that your backend workflow knows what to receive, take /initialize
out of your URL and reinitialize so your API call knows what the response structure is
Thanks for the tip on the authorization, that’s working now.
However, that wasn’t stopping me from getting return values because I was just allowing the workflow to be run without authentication. See above for the screenshots showing what I’m returning in the workflow and what’s actually being returned. Any idea why the Companies list wouldn’t be returned?
Try returning a list of texts, and doing Companyies:each item’s unique ID. Then on your initialization pick Company for the type again. I think it turns the unique IDs back into the “thing”
I was hopeful for that idea but I changed to text and re-initialized - no dice.
I even changed the return to just send one Company unique id back and it’s still giving the same result. I changed to just send a Company unique id I manually pasted in the return field and again, same result.
Looks like he did based on his response but what he should have done is just call his regular endpoint which will return customers. Don’t need initialize on it just initialize in the api connector
1 Like
@tylerboodman I did remove the /initialize but I didn’t re-initialize after that. I just tried that and it worked. I had thought the point of the first initialization was to get the fields; not sure why it wouldn’t send the actual data format for a response when initializing but hey, now I get how it works. Thanks!
1 Like