How to use API "Return data from API"

I want to develop API which returns text, so I am trying to use “Return data from API” on Backend workflow like below:
Screen Shot 2022-01-19 at 16.32.25

When I call API on the application page, it gets unknown numbers such as 11747 which is incremental.
Screen Shot 2022-01-19 at 16.36.28
Screen Shot 2022-01-19 at 16.36.37

If anyone knows the way to create API that returns text defined on Editor.

Thank you in advance.

3 Likes

consider returning JSON as type in your API. That is standard.

for working with text properties WITHIN a json response just use the following

-property named “mytxt”

  • above property value can be any text value that u want
1 Like

Hi @rowntreerob

You are right, but I am still in trouble, it could be the bug of Bubble.
I changed the workflow like this
Screen Shot 2022-01-19 at 17.30.45

But returned value is the same.
I am wondering why there is no suggestion to access “mytext” parameter.

1 Like

may help review some “how to” docs

https://manual.bubble.io/core-resources/api/data-api
for using bubble to produce json response from a bubble api

NOTE “json response” does NOT mean that there are no json properties of type text in the response.

2nd suggest json response for integromat

see below for sample of JSON response ( ie the enclosing braces ) where there are contain within , type text props ( json obj at 1 contains “filename” , “path” which are text )

1 Like

Thank you so much for your suggestion.

I succeeded in getting the expected result of the API via API Connector.

1 Like

running into the same issue. what was the solution?

3 Likes

When you call an endpoint using the Schedule API workflow from an action within a workflow you’re not able to retrieve any returned data from that workflow. Instead, you’ll always receive the ID of the scheduled workflow.

To work around this you need to build the call into the API Connector, make the call directly to your own app, and then you’ll receive back any returned values.

The call would be setup as below, and then (once it’s initialised) it will show as an available action within your workflows. All subsequent steps will have access to the response values, and will wait a response if you create that dependency.

25 Likes

Thx much - it’s what I ended up doing!

Thanks for the solution.

Although bubble made it a bit over-complicated if you use backend services for internal workflows only

4 Likes

Agreed - not straight forward. For most people using a database trigger is probably a better route.

Hi @exception-rambler

I have not yet explored this feature and feel it may be suitable for my use case and prior to going down the path to try and implement it I was curious if you think it is a suitable approach for the use case.

In the app I need to perform a search of the database and the data values needed for constraints are hidden by privacy rules as the goal is to have a algorithm of sorts.

Would you think using the return data from api is the correct approach for a use case like this since I could ‘ignore privacy rules’ in the backend workflows to still access the values hidden by privacy rules and then have the search results returned to be displayed on the page?

I’d imagine I’d be setting up a GET call for my Bubble app to be run in the backend workflow.

Hey @boston85719 yeh that seems to make sense to me.

Call it via POST or (newly) GET - as its your own endpoint its a design choice rather than a technical one.

In my experience results not as snappy as using the data API but are fine.
No real gotchas and should only take you 10 mins to spin up. Add some exception handling on the f/e just in case.

With this system you can check information on a thing without exposing any properties, and the information is completely private. You ONLY return what the user needs to see.

1 Like

Thanks @exception-rambler

Never knew that, so definitely insightful.

I suppose then that I might be able to in the repeating group have the datasource be the data API which would essentially do the same thing of keeping the algorithmic data components hidden through privacy rules.

Thanks again.

1 Like

@GH5T Thank you for that explanation and link. Definitely helpful in preparing.

Obrigado por compartilhar o conhecimento.

Please can someone explain where he got the post link? and what the rest of the parameters on the screenshot are?

@exception-rambler Can you share how you did the authentication portion of the API Connector setup, to access your own Bubble API?

1 Like

You find your base url for the API in your settings > API. You’ll see the “workflow API root url”.
The parameters passed are those defined by you in your Backend API workflow.

So the endpoint URL would be your API root url plus the api workflow slug (the name you give to it). Set it as a “POST” call, add the parameters you have set in your Backend API Workflow and it should be good to go.

2 Likes

Huge thank you!